From 9d8998443c219d8851e5a9a640cba79e14aea443 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 19 Apr 2020 23:28:22 +0800 Subject: [PATCH] add some scripts --- tests/script/general/account/monitor.sim | 36 + tests/script/general/account/pass_alter.sim | 49 + tests/script/general/account/pass_len.sim | 83 ++ tests/script/general/account/testSuite.sim | 5 + tests/script/general/account/user_create.sim | 87 ++ tests/script/general/account/user_len.sim | 88 ++ tests/script/general/agg/fill.sim | 63 + tests/script/general/agg/stream.sim | 316 +++++ tests/script/general/agg/testSuite.sim | 2 + .../alter/cached_schema_after_alter.sim | 119 ++ tests/script/general/alter/count.sim | 266 ++++ tests/script/general/alter/import.sim | 49 + tests/script/general/alter/insert1.sim | 1150 +++++++++++++++ tests/script/general/alter/insert2.sim | 683 +++++++++ tests/script/general/alter/metrics.sim | 783 +++++++++++ tests/script/general/alter/table.sim | 686 +++++++++ tests/script/general/alter/testSuite.sim | 7 + tests/script/general/cache/cache_balance.sim | 58 + tests/script/general/cache/new_metrics.sim | 146 ++ tests/script/general/cache/new_stream.sim | 108 ++ .../script/general/cache/restart_metrics.sim | 87 ++ tests/script/general/cache/restart_stream.sim | 179 +++ tests/script/general/cache/restart_table.sim | 61 + tests/script/general/cache/testSuite.sim | 5 + tests/script/general/column/commit.sim | 154 ++ tests/script/general/column/metrics.sim | 217 +++ tests/script/general/column/stream.sim | 200 +++ tests/script/general/column/table.sim | 213 +++ tests/script/general/column/testSuite.sim | 4 + tests/script/general/compress/commitlog.sim | 128 ++ tests/script/general/compress/compress.sim | 123 ++ tests/script/general/compress/compress2.sim | 123 ++ tests/script/general/compress/testSuite.sim | 4 + tests/script/general/compress/uncompress.sim | 123 ++ tests/script/general/compute/avg.sim | 156 +++ tests/script/general/compute/bottom.sim | 97 ++ tests/script/general/compute/count.sim | 172 +++ tests/script/general/compute/diff.sim | 89 ++ tests/script/general/compute/diff2.sim | 155 +++ tests/script/general/compute/first.sim | 158 +++ tests/script/general/compute/interval.sim | 174 +++ tests/script/general/compute/last.sim | 157 +++ tests/script/general/compute/leastsquare.sim | 98 ++ tests/script/general/compute/max.sim | 157 +++ tests/script/general/compute/min.sim | 158 +++ tests/script/general/compute/null.sim | 225 +++ tests/script/general/compute/percentile.sim | 114 ++ tests/script/general/compute/stddev.sim | 96 ++ tests/script/general/compute/sum.sim | 157 +++ tests/script/general/compute/testSuite.sim | 16 + tests/script/general/compute/top.sim | 97 ++ tests/script/general/db/back_insert.sim | 7 + tests/script/general/db/backup/keep.sim | 209 +++ tests/script/general/db/basic.sim | 204 +++ tests/script/general/db/delete_reuse1.sim | 110 ++ tests/script/general/db/delete_reuse2.sim | 117 ++ tests/script/general/db/delete_reusevnode.sim | 121 ++ .../script/general/db/delete_reusevnode2.sim | 79 ++ tests/script/general/db/delete_writing1.sim | 59 + tests/script/general/db/delete_writing2.sim | 47 + tests/script/general/db/len.sim | 94 ++ tests/script/general/db/repeat.sim | 71 + tests/script/general/db/tables.sim | 126 ++ tests/script/general/db/testSuite.sim | 7 + tests/script/general/field/2.sim | 295 ++++ tests/script/general/field/3.sim | 521 +++++++ tests/script/general/field/4.sim | 711 ++++++++++ tests/script/general/field/5.sim | 834 +++++++++++ tests/script/general/field/6.sim | 989 +++++++++++++ tests/script/general/field/bigint.sim | 160 +++ tests/script/general/field/binary.sim | 84 ++ tests/script/general/field/bool.sim | 161 +++ tests/script/general/field/double.sim | 160 +++ tests/script/general/field/float.sim | 160 +++ tests/script/general/field/int.sim | 160 +++ tests/script/general/field/single.sim | 218 +++ tests/script/general/field/smallint.sim | 160 +++ tests/script/general/field/testSuite.sim | 14 + tests/script/general/field/tinyint.sim | 161 +++ tests/script/general/http/bug.go | 329 +++++ tests/script/general/http/grafana.sim | 182 +++ tests/script/general/http/grafana_bug.sim | 239 ++++ tests/script/general/http/http.json | 23 + tests/script/general/http/httpTestNew.go | 232 ++++ tests/script/general/http/httpTest_cloud.go | 372 +++++ tests/script/general/http/httpTest_private.go | 372 +++++ tests/script/general/http/opentsdb.sim | 238 ++++ tests/script/general/http/prepare.sim | 54 + tests/script/general/http/restful.sim | 84 ++ tests/script/general/http/restful_full.sim | 234 ++++ tests/script/general/http/restful_insert.sim | 53 + tests/script/general/http/restful_limit.sim | 45 + tests/script/general/http/taos.json | 23 + tests/script/general/http/taos_cloud.json | 21 + tests/script/general/http/telegraf.json | 7 + tests/script/general/http/telegraf.req | 621 +++++++++ tests/script/general/http/telegraf.sim | 293 ++++ tests/script/general/http/telegrafTest.go | 223 +++ tests/script/general/http/telegraf_help.txt | 24 + tests/script/general/http/testSuite.sim | 7 + tests/script/general/import/basic.sim | 156 +++ tests/script/general/import/commit.sim | 103 ++ tests/script/general/import/large.sim | 107 ++ tests/script/general/import/replica1.sim | 176 +++ tests/script/general/import/testSuite.sim | 4 + tests/script/general/insert/basic.sim | 49 + tests/script/general/insert/insert_drop.sim | 83 ++ .../general/insert/query_block1_file.sim | 195 +++ .../general/insert/query_block1_memory.sim | 177 +++ .../general/insert/query_block2_file.sim | 210 +++ .../general/insert/query_block2_memory.sim | 172 +++ .../general/insert/query_file_memory.sim | 209 +++ .../general/insert/query_multi_file.sim | 55 + tests/script/general/insert/tcp.sim | 40 + tests/script/general/insert/testSuite.sim | 8 + tests/script/general/metrics/disk.sim | 197 +++ tests/script/general/metrics/metrics.sim | 137 ++ tests/script/general/metrics/testSuite.sim | 4 + tests/script/general/metrics/values.sim | 126 ++ tests/script/general/metrics/vnode3.sim | 178 +++ tests/script/general/parser/README.txt | 27 + tests/script/general/parser/alter.sim | 241 ++++ tests/script/general/parser/alter1.sim | 135 ++ tests/script/general/parser/alter_stable.sim | 43 + .../script/general/parser/auto_create_tb.sim | 306 ++++ .../general/parser/auto_create_tb_drop_tb.sim | 83 ++ .../general/parser/binary_escapeCharacter.sim | 104 ++ tests/script/general/parser/bug.sim | 45 + .../parser/col_arithmetic_operation.sim | 93 ++ tests/script/general/parser/columnValue.sim | 37 + .../general/parser/columnValue_bigint.sim | 466 +++++++ .../general/parser/columnValue_bool.sim | 630 +++++++++ .../general/parser/columnValue_double.sim | 524 +++++++ .../general/parser/columnValue_float.sim | 524 +++++++ .../script/general/parser/columnValue_int.sim | 465 +++++++ .../general/parser/columnValue_smallint.sim | 465 +++++++ .../general/parser/columnValue_tinyint.sim | 465 +++++++ tests/script/general/parser/commit.sim | 109 ++ tests/script/general/parser/create_db.sim | 190 +++ tests/script/general/parser/create_mt.sim | 260 ++++ tests/script/general/parser/create_tb.sim | 190 +++ .../general/parser/dbtbnameValidate.sim | 131 ++ tests/script/general/parser/fill.sim | 851 ++++++++++++ tests/script/general/parser/fill_stb.sim | 432 ++++++ tests/script/general/parser/first_last.sim | 83 ++ .../general/parser/first_last_query.sim | 135 ++ tests/script/general/parser/groupby.sim | 409 ++++++ tests/script/general/parser/import.sim | 91 ++ .../script/general/parser/import_commit1.sim | 55 + .../script/general/parser/import_commit2.sim | 54 + .../script/general/parser/import_commit3.sim | 61 + tests/script/general/parser/import_file.sim | 37 + .../script/general/parser/insert_multiTbl.sim | 68 + tests/script/general/parser/insert_tb.sim | 235 ++++ tests/script/general/parser/interp.sim | 67 + tests/script/general/parser/interp_test.sim | 834 +++++++++++ tests/script/general/parser/join.sim | 446 ++++++ .../script/general/parser/join_multivnode.sim | 130 ++ tests/script/general/parser/lastrow.sim | 70 + tests/script/general/parser/lastrow_query.sim | 51 + tests/script/general/parser/limit.sim | 71 + tests/script/general/parser/limit1.sim | 69 + tests/script/general/parser/limit1_stb.sim | 693 +++++++++ tests/script/general/parser/limit1_tb.sim | 1154 +++++++++++++++ .../general/parser/limit1_tblocks100.sim | 69 + tests/script/general/parser/limit2.sim | 76 + tests/script/general/parser/limit2_query.sim | 325 +++++ .../general/parser/limit2_tblocks100.sim | 76 + tests/script/general/parser/limit_stb.sim | 1235 +++++++++++++++++ tests/script/general/parser/limit_tb.sim | 1137 +++++++++++++++ tests/script/general/parser/mixed_blocks.sim | 144 ++ tests/script/general/parser/nchar.sim | 310 +++++ tests/script/general/parser/null_char.sim | 491 +++++++ .../parser/projection_limit_offset.sim | 378 +++++ tests/script/general/parser/repeatAlter.sim | 7 + tests/script/general/parser/repeatStream.sim | 7 + tests/script/general/parser/selectResNum.sim | 184 +++ .../general/parser/select_across_vnodes.sim | 82 ++ .../general/parser/select_from_cache_disk.sim | 70 + .../general/parser/select_with_tags.sim | 840 +++++++++++ tests/script/general/parser/set_tag_vals.sim | 227 +++ .../general/parser/single_row_in_tb.sim | 38 + .../general/parser/single_row_in_tb_query.sim | 194 +++ tests/script/general/parser/slimit.sim | 107 ++ tests/script/general/parser/slimit1.sim | 66 + tests/script/general/parser/slimit1_query.sim | 184 +++ .../general/parser/slimit_alter_tags.sim | 257 ++++ tests/script/general/parser/slimit_query.sim | 572 ++++++++ tests/script/general/parser/stream.sim | 223 +++ tests/script/general/parser/stream_on_sys.sim | 60 + .../parser/tags_dynamically_specifiy.sim | 58 + tests/script/general/parser/tags_filter.sim | 106 ++ tests/script/general/parser/tbnameIn.sim | 75 + .../script/general/parser/tbnameIn_query.sim | 433 ++++++ tests/script/general/parser/testSuite.sim | 92 ++ tests/script/general/parser/timestamp.sim | 67 + .../script/general/parser/timestamp_query.sim | 33 + tests/script/general/parser/where.sim | 274 ++++ tests/script/general/stream/metrics_1.sim | 287 ++++ tests/script/general/stream/metrics_del.sim | 98 ++ tests/script/general/stream/metrics_n.sim | 262 ++++ .../stream/metrics_replica1_vnoden.sim | 245 ++++ tests/script/general/stream/stream_1.sim | 206 +++ tests/script/general/stream/stream_2.sim | 194 +++ tests/script/general/stream/stream_3.sim | 204 +++ .../script/general/stream/stream_restart.sim | 142 ++ tests/script/general/stream/table_1.sim | 317 +++++ tests/script/general/stream/table_del.sim | 93 ++ tests/script/general/stream/table_n.sim | 291 ++++ .../general/stream/table_replica1_vnoden.sim | 299 ++++ tests/script/general/stream/testSuite.sim | 12 + tests/script/general/table/back_insert.sim | 7 + tests/script/general/table/bigint.sim | 73 + tests/script/general/table/binary.sim | 63 + tests/script/general/table/bool.sim | 92 ++ tests/script/general/table/column2.sim | 26 + tests/script/general/table/column_name.sim | 90 ++ tests/script/general/table/column_num.sim | 85 ++ tests/script/general/table/column_value.sim | 82 ++ tests/script/general/table/date.sim | 90 ++ tests/script/general/table/db.table.sim | 47 + tests/script/general/table/delete_reuse1.sim | 89 ++ tests/script/general/table/delete_reuse2.sim | 91 ++ tests/script/general/table/delete_writing.sim | 59 + tests/script/general/table/describe.sim | 50 + tests/script/general/table/double.sim | 98 ++ tests/script/general/table/float.sim | 98 ++ tests/script/general/table/int.sim | 135 ++ tests/script/general/table/limit.sim | 94 ++ tests/script/general/table/smallint.sim | 105 ++ tests/script/general/table/table.sim | 226 +++ tests/script/general/table/table_len.sim | 105 ++ tests/script/general/table/testSuite.sim | 22 + tests/script/general/table/tinyint.sim | 104 ++ tests/script/general/table/vgroup.sim | 162 +++ tests/script/general/tag/3.sim | 523 +++++++ tests/script/general/tag/4.sim | 713 ++++++++++ tests/script/general/tag/5.sim | 836 +++++++++++ tests/script/general/tag/6.sim | 991 +++++++++++++ tests/script/general/tag/add.sim | 854 ++++++++++++ tests/script/general/tag/bigint.sim | 242 ++++ tests/script/general/tag/binary.sim | 242 ++++ tests/script/general/tag/binary_binary.sim | 309 +++++ tests/script/general/tag/bool.sim | 239 ++++ tests/script/general/tag/bool_binary.sim | 309 +++++ tests/script/general/tag/bool_int.sim | 325 +++++ tests/script/general/tag/change.sim | 514 +++++++ tests/script/general/tag/column.sim | 94 ++ tests/script/general/tag/commit.sim | 1183 ++++++++++++++++ tests/script/general/tag/create.sim | 600 ++++++++ tests/script/general/tag/delete.sim | 826 +++++++++++ tests/script/general/tag/double.sim | 242 ++++ tests/script/general/tag/filter.sim | 148 ++ tests/script/general/tag/float.sim | 242 ++++ tests/script/general/tag/int.sim | 242 ++++ tests/script/general/tag/int_binary.sim | 309 +++++ tests/script/general/tag/int_float.sim | 325 +++++ tests/script/general/tag/set.sim | 458 ++++++ tests/script/general/tag/smallint.sim | 242 ++++ tests/script/general/tag/testSuite.sim | 25 + tests/script/general/tag/tinyint.sim | 242 ++++ tests/script/general/vector/metrics_field.sim | 621 +++++++++ tests/script/general/vector/metrics_mix.sim | 621 +++++++++ tests/script/general/vector/metrics_query.sim | 617 ++++++++ tests/script/general/vector/metrics_tag.sim | 617 ++++++++ tests/script/general/vector/metrics_time.sim | 617 ++++++++ tests/script/general/vector/multi.sim | 215 +++ tests/script/general/vector/single.sim | 301 ++++ tests/script/general/vector/table_field.sim | 617 ++++++++ tests/script/general/vector/table_mix.sim | 617 ++++++++ tests/script/general/vector/table_query.sim | 617 ++++++++ tests/script/general/vector/table_time.sim | 617 ++++++++ tests/script/general/vector/testSuite.sim | 12 + .../script/unique/account/account_create.sim | 82 ++ .../script/unique/account/account_delete.sim | 91 ++ tests/script/unique/account/account_len.sim | 92 ++ tests/script/unique/account/authority.sim | 346 +++++ tests/script/unique/account/monitor.sim | 36 + tests/script/unique/account/pass_alter.sim | 115 ++ tests/script/unique/account/pass_len.sim | 83 ++ tests/script/unique/account/testSuite.sim | 9 + tests/script/unique/account/user_create.sim | 87 ++ tests/script/unique/account/user_len.sim | 93 ++ tests/script/unique/big/balance.sim | 312 +++++ tests/script/unique/big/maxvnodes.sim | 81 ++ tests/script/unique/big/tcp.sim | 107 ++ tests/script/unique/big/testSuite.sim | 3 + .../script/unique/cluster/backup/balance4.sim | 759 ++++++++++ .../script/unique/cluster/backup/balance5.sim | 413 ++++++ .../script/unique/cluster/backup/balancex.sim | 372 +++++ tests/script/unique/cluster/balance1.sim | 813 +++++++++++ tests/script/unique/cluster/balance1_bug.sim | 800 +++++++++++ .../script/unique/cluster/balance1_single.sim | 729 ++++++++++ tests/script/unique/cluster/balance2.sim | 787 +++++++++++ tests/script/unique/cluster/balance3.sim | 619 +++++++++ tests/script/unique/cluster/testSuite.sim | 5 + tests/script/unique/column/replica3.sim | 39 + tests/script/unique/column/testSuite.sim | 1 + tests/script/unique/db/back_insert.sim | 7 + tests/script/unique/db/commit.sim | 120 ++ tests/script/unique/db/delete.sim | 49 + tests/script/unique/db/delete_part.sim | 79 ++ tests/script/unique/db/replica_add12.sim | 232 ++++ tests/script/unique/db/replica_add13.sim | 268 ++++ tests/script/unique/db/replica_add23.sim | 280 ++++ tests/script/unique/db/replica_part.sim | 196 +++ tests/script/unique/db/replica_reduce21.sim | 152 ++ tests/script/unique/db/replica_reduce31.sim | 220 +++ tests/script/unique/db/replica_reduce32.sim | 188 +++ tests/script/unique/db/testSuite.sim | 10 + tests/script/unique/dnode/backup/balance4.sim | 435 ++++++ tests/script/unique/dnode/backup/balance5.sim | 469 +++++++ tests/script/unique/dnode/backup/unremove.sim | 149 ++ tests/script/unique/dnode/balance1.sim | 336 +++++ tests/script/unique/dnode/balance2.sim | 285 ++++ tests/script/unique/dnode/balance3.sim | 317 +++++ tests/script/unique/dnode/balancex.sim | 213 +++ tests/script/unique/dnode/monitor_bug.sim | 70 + tests/script/unique/dnode/offline1.sim | 76 + tests/script/unique/dnode/offline2.sim | 104 ++ tests/script/unique/dnode/remove1.sim | 211 +++ tests/script/unique/dnode/remove2.sim | 157 +++ tests/script/unique/dnode/testSuite.sim | 13 + tests/script/unique/dnode/vnode_clean.sim | 321 +++++ tests/script/unique/http/admin.sim | 180 +++ tests/script/unique/http/testSuite.sim | 1 + tests/script/unique/import/replica2.sim | 220 +++ tests/script/unique/import/replica3.sim | 198 +++ tests/script/unique/import/testSuite.sim | 2 + .../unique/metrics/balance_replica1.sim | 141 ++ tests/script/unique/metrics/dnode2.sim | 198 +++ tests/script/unique/metrics/dnode2_stop.sim | 151 ++ tests/script/unique/metrics/dnode3.sim | 227 +++ .../script/unique/metrics/replica2_dnode4.sim | 218 +++ .../script/unique/metrics/replica2_vnode3.sim | 195 +++ .../script/unique/metrics/replica3_dnode6.sim | 248 ++++ .../script/unique/metrics/replica3_vnode3.sim | 217 +++ tests/script/unique/metrics/testSuite.sim | 4 + tests/script/unique/mnode/backup/mgmt44.sim | 240 ++++ tests/script/unique/mnode/backup/mgmt45.sim | 336 +++++ tests/script/unique/mnode/backup/mgmt55.sim | 328 +++++ tests/script/unique/mnode/backup/mgmt56.sim | 394 ++++++ tests/script/unique/mnode/backup/mgmt57.sim | 408 ++++++ tests/script/unique/mnode/drop.sim | 96 ++ tests/script/unique/mnode/mgmt22.sim | 155 +++ tests/script/unique/mnode/mgmt23.sim | 173 +++ tests/script/unique/mnode/mgmt24.sim | 112 ++ tests/script/unique/mnode/mgmt25.sim | 96 ++ tests/script/unique/mnode/mgmt26.sim | 146 ++ tests/script/unique/mnode/mgmt33.sim | 182 +++ tests/script/unique/mnode/mgmt34.sim | 232 ++++ tests/script/unique/mnode/mgmtr1.sim | 107 ++ tests/script/unique/mnode/mgmtr2.sim | 85 ++ tests/script/unique/mnode/reuse.sim | 97 ++ tests/script/unique/mnode/secondIp.sim | 35 + tests/script/unique/mnode/tcp_mgmt22.sim | 155 +++ tests/script/unique/mnode/testSuite.sim | 13 + .../script/unique/stream/metrics_balance.sim | 320 +++++ .../unique/stream/metrics_replica1_dnode2.sim | 262 ++++ .../unique/stream/metrics_replica2_dnode2.sim | 260 ++++ .../stream/metrics_replica2_dnode2_vnoden.sim | 263 ++++ .../unique/stream/metrics_replica2_dnode3.sim | 273 ++++ .../unique/stream/metrics_replica3_dnode4.sim | 284 ++++ .../unique/stream/metrics_vnode_stop.sim | 188 +++ tests/script/unique/stream/table_balance.sim | 244 ++++ tests/script/unique/stream/table_move.sim | 279 ++++ .../unique/stream/table_replica1_dnode2.sim | 141 ++ .../unique/stream/table_replica2_dnode2.sim | 312 +++++ .../stream/table_replica2_dnode2_vnoden.sim | 316 +++++ .../unique/stream/table_replica2_dnode3.sim | 328 +++++ .../unique/stream/table_replica3_dnode4.sim | 337 +++++ .../script/unique/stream/table_vnode_stop.sim | 189 +++ tests/script/unique/stream/testSuite.sim | 15 + tests/script/unique/table/back_insert.sim | 7 + tests/script/unique/table/delete_part.sim | 82 ++ tests/script/unique/table/testSuite.sim | 1 + tests/script/unique/vnode/back_insert.sim | 7 + .../script/unique/vnode/back_insert_many.sim | 10 + tests/script/unique/vnode/backup/replica4.sim | 220 +++ tests/script/unique/vnode/backup/replica5.sim | 263 ++++ tests/script/unique/vnode/commit.sim | 152 ++ tests/script/unique/vnode/many.sim | 119 ++ tests/script/unique/vnode/replica2_basic.sim | 193 +++ tests/script/unique/vnode/replica2_basic2.sim | 215 +++ tests/script/unique/vnode/replica2_repeat.sim | 77 + tests/script/unique/vnode/replica3_basic.sim | 158 +++ tests/script/unique/vnode/replica3_repeat.sim | 86 ++ tests/script/unique/vnode/replica3_vgroup.sim | 67 + tests/script/unique/vnode/testSuite.sim | 9 + tests/script/windows/account/authority.sim | 317 +++++ tests/script/windows/account/user_create.sim | 80 ++ tests/script/windows/account/user_len.sim | 81 ++ tests/script/windows/alter/metrics.sim | 776 +++++++++++ tests/script/windows/alter/table.sim | 679 +++++++++ tests/script/windows/compute/avg.sim | 151 ++ tests/script/windows/compute/bottom.sim | 92 ++ tests/script/windows/compute/count.sim | 167 +++ tests/script/windows/compute/diff.sim | 84 ++ tests/script/windows/compute/first.sim | 153 ++ tests/script/windows/compute/interval.sim | 169 +++ tests/script/windows/compute/last.sim | 152 ++ tests/script/windows/compute/leastsquare.sim | 93 ++ tests/script/windows/compute/max.sim | 152 ++ tests/script/windows/compute/min.sim | 152 ++ tests/script/windows/compute/percentile.sim | 109 ++ tests/script/windows/compute/stddev.sim | 91 ++ tests/script/windows/compute/sum.sim | 152 ++ tests/script/windows/compute/top.sim | 92 ++ tests/script/windows/db/basic.sim | 191 +++ tests/script/windows/db/len.sim | 85 ++ tests/script/windows/field/2.sim | 288 ++++ tests/script/windows/field/3.sim | 514 +++++++ tests/script/windows/field/4.sim | 704 ++++++++++ tests/script/windows/field/5.sim | 827 +++++++++++ tests/script/windows/field/6.sim | 982 +++++++++++++ tests/script/windows/field/bigint.sim | 153 ++ tests/script/windows/field/binary.sim | 77 + tests/script/windows/field/bool.sim | 154 ++ tests/script/windows/field/double.sim | 153 ++ tests/script/windows/field/float.sim | 153 ++ tests/script/windows/field/int.sim | 153 ++ tests/script/windows/field/single.sim | 211 +++ tests/script/windows/field/smallint.sim | 153 ++ tests/script/windows/field/tinyint.sim | 153 ++ tests/script/windows/import/basic.sim | 117 ++ tests/script/windows/insert/basic.sim | 42 + .../windows/insert/query_block1_file.sim | 188 +++ .../windows/insert/query_block1_memory.sim | 170 +++ .../windows/insert/query_block2_file.sim | 203 +++ .../windows/insert/query_block2_memory.sim | 165 +++ .../windows/insert/query_file_memory.sim | 202 +++ .../windows/insert/query_multi_file.sim | 48 + tests/script/windows/table/binary.sim | 55 + tests/script/windows/table/bool.sim | 85 ++ tests/script/windows/table/column_name.sim | 83 ++ tests/script/windows/table/column_num.sim | 78 ++ tests/script/windows/table/column_value.sim | 75 + tests/script/windows/table/db.table.sim | 40 + tests/script/windows/table/double.sim | 91 ++ tests/script/windows/table/float.sim | 91 ++ tests/script/windows/table/table.sim | 218 +++ tests/script/windows/table/table_len.sim | 98 ++ tests/script/windows/tag/3.sim | 514 +++++++ tests/script/windows/tag/4.sim | 704 ++++++++++ tests/script/windows/tag/5.sim | 827 +++++++++++ tests/script/windows/tag/6.sim | 982 +++++++++++++ tests/script/windows/tag/add.sim | 844 +++++++++++ tests/script/windows/tag/bigint.sim | 234 ++++ tests/script/windows/tag/binary.sim | 234 ++++ tests/script/windows/tag/binary_binary.sim | 301 ++++ tests/script/windows/tag/bool.sim | 231 +++ tests/script/windows/tag/bool_binary.sim | 301 ++++ tests/script/windows/tag/bool_int.sim | 317 +++++ tests/script/windows/tag/change.sim | 506 +++++++ tests/script/windows/tag/column.sim | 86 ++ tests/script/windows/tag/create.sim | 591 ++++++++ tests/script/windows/tag/delete.sim | 818 +++++++++++ tests/script/windows/tag/double.sim | 234 ++++ tests/script/windows/tag/filter.sim | 145 ++ tests/script/windows/tag/float.sim | 234 ++++ tests/script/windows/tag/int.sim | 234 ++++ tests/script/windows/tag/int_binary.sim | 301 ++++ tests/script/windows/tag/int_float.sim | 317 +++++ tests/script/windows/tag/set.sim | 450 ++++++ tests/script/windows/tag/smallint.sim | 234 ++++ tests/script/windows/tag/tinyint.sim | 234 ++++ tests/script/windows/testSuite.sim | 97 ++ tests/script/windows/vector/metrics_field.sim | 615 ++++++++ tests/script/windows/vector/metrics_mix.sim | 615 ++++++++ tests/script/windows/vector/metrics_query.sim | 611 ++++++++ tests/script/windows/vector/metrics_tag.sim | 611 ++++++++ tests/script/windows/vector/metrics_time.sim | 611 ++++++++ tests/script/windows/vector/multi.sim | 209 +++ tests/script/windows/vector/single.sim | 295 ++++ tests/script/windows/vector/table_field.sim | 611 ++++++++ tests/script/windows/vector/table_mix.sim | 611 ++++++++ tests/script/windows/vector/table_query.sim | 611 ++++++++ tests/script/windows/vector/table_time.sim | 611 ++++++++ 478 files changed, 112836 insertions(+) create mode 100644 tests/script/general/account/monitor.sim create mode 100644 tests/script/general/account/pass_alter.sim create mode 100644 tests/script/general/account/pass_len.sim create mode 100644 tests/script/general/account/testSuite.sim create mode 100644 tests/script/general/account/user_create.sim create mode 100644 tests/script/general/account/user_len.sim create mode 100644 tests/script/general/agg/fill.sim create mode 100644 tests/script/general/agg/stream.sim create mode 100644 tests/script/general/agg/testSuite.sim create mode 100644 tests/script/general/alter/cached_schema_after_alter.sim create mode 100644 tests/script/general/alter/count.sim create mode 100644 tests/script/general/alter/import.sim create mode 100644 tests/script/general/alter/insert1.sim create mode 100644 tests/script/general/alter/insert2.sim create mode 100644 tests/script/general/alter/metrics.sim create mode 100644 tests/script/general/alter/table.sim create mode 100644 tests/script/general/alter/testSuite.sim create mode 100644 tests/script/general/cache/cache_balance.sim create mode 100644 tests/script/general/cache/new_metrics.sim create mode 100644 tests/script/general/cache/new_stream.sim create mode 100644 tests/script/general/cache/restart_metrics.sim create mode 100644 tests/script/general/cache/restart_stream.sim create mode 100644 tests/script/general/cache/restart_table.sim create mode 100644 tests/script/general/cache/testSuite.sim create mode 100644 tests/script/general/column/commit.sim create mode 100644 tests/script/general/column/metrics.sim create mode 100644 tests/script/general/column/stream.sim create mode 100644 tests/script/general/column/table.sim create mode 100644 tests/script/general/column/testSuite.sim create mode 100644 tests/script/general/compress/commitlog.sim create mode 100644 tests/script/general/compress/compress.sim create mode 100644 tests/script/general/compress/compress2.sim create mode 100644 tests/script/general/compress/testSuite.sim create mode 100644 tests/script/general/compress/uncompress.sim create mode 100644 tests/script/general/compute/avg.sim create mode 100644 tests/script/general/compute/bottom.sim create mode 100644 tests/script/general/compute/count.sim create mode 100644 tests/script/general/compute/diff.sim create mode 100644 tests/script/general/compute/diff2.sim create mode 100644 tests/script/general/compute/first.sim create mode 100644 tests/script/general/compute/interval.sim create mode 100644 tests/script/general/compute/last.sim create mode 100644 tests/script/general/compute/leastsquare.sim create mode 100644 tests/script/general/compute/max.sim create mode 100644 tests/script/general/compute/min.sim create mode 100644 tests/script/general/compute/null.sim create mode 100644 tests/script/general/compute/percentile.sim create mode 100644 tests/script/general/compute/stddev.sim create mode 100644 tests/script/general/compute/sum.sim create mode 100644 tests/script/general/compute/testSuite.sim create mode 100644 tests/script/general/compute/top.sim create mode 100644 tests/script/general/db/back_insert.sim create mode 100644 tests/script/general/db/backup/keep.sim create mode 100644 tests/script/general/db/basic.sim create mode 100644 tests/script/general/db/delete_reuse1.sim create mode 100644 tests/script/general/db/delete_reuse2.sim create mode 100644 tests/script/general/db/delete_reusevnode.sim create mode 100644 tests/script/general/db/delete_reusevnode2.sim create mode 100644 tests/script/general/db/delete_writing1.sim create mode 100644 tests/script/general/db/delete_writing2.sim create mode 100644 tests/script/general/db/len.sim create mode 100644 tests/script/general/db/repeat.sim create mode 100644 tests/script/general/db/tables.sim create mode 100644 tests/script/general/db/testSuite.sim create mode 100644 tests/script/general/field/2.sim create mode 100644 tests/script/general/field/3.sim create mode 100644 tests/script/general/field/4.sim create mode 100644 tests/script/general/field/5.sim create mode 100644 tests/script/general/field/6.sim create mode 100644 tests/script/general/field/bigint.sim create mode 100644 tests/script/general/field/binary.sim create mode 100644 tests/script/general/field/bool.sim create mode 100644 tests/script/general/field/double.sim create mode 100644 tests/script/general/field/float.sim create mode 100644 tests/script/general/field/int.sim create mode 100644 tests/script/general/field/single.sim create mode 100644 tests/script/general/field/smallint.sim create mode 100644 tests/script/general/field/testSuite.sim create mode 100644 tests/script/general/field/tinyint.sim create mode 100644 tests/script/general/http/bug.go create mode 100644 tests/script/general/http/grafana.sim create mode 100644 tests/script/general/http/grafana_bug.sim create mode 100644 tests/script/general/http/http.json create mode 100644 tests/script/general/http/httpTestNew.go create mode 100644 tests/script/general/http/httpTest_cloud.go create mode 100644 tests/script/general/http/httpTest_private.go create mode 100644 tests/script/general/http/opentsdb.sim create mode 100644 tests/script/general/http/prepare.sim create mode 100644 tests/script/general/http/restful.sim create mode 100644 tests/script/general/http/restful_full.sim create mode 100644 tests/script/general/http/restful_insert.sim create mode 100644 tests/script/general/http/restful_limit.sim create mode 100644 tests/script/general/http/taos.json create mode 100644 tests/script/general/http/taos_cloud.json create mode 100644 tests/script/general/http/telegraf.json create mode 100644 tests/script/general/http/telegraf.req create mode 100644 tests/script/general/http/telegraf.sim create mode 100644 tests/script/general/http/telegrafTest.go create mode 100644 tests/script/general/http/telegraf_help.txt create mode 100644 tests/script/general/http/testSuite.sim create mode 100644 tests/script/general/import/basic.sim create mode 100644 tests/script/general/import/commit.sim create mode 100644 tests/script/general/import/large.sim create mode 100644 tests/script/general/import/replica1.sim create mode 100644 tests/script/general/import/testSuite.sim create mode 100644 tests/script/general/insert/basic.sim create mode 100644 tests/script/general/insert/insert_drop.sim create mode 100644 tests/script/general/insert/query_block1_file.sim create mode 100644 tests/script/general/insert/query_block1_memory.sim create mode 100644 tests/script/general/insert/query_block2_file.sim create mode 100644 tests/script/general/insert/query_block2_memory.sim create mode 100644 tests/script/general/insert/query_file_memory.sim create mode 100644 tests/script/general/insert/query_multi_file.sim create mode 100644 tests/script/general/insert/tcp.sim create mode 100644 tests/script/general/insert/testSuite.sim create mode 100644 tests/script/general/metrics/disk.sim create mode 100644 tests/script/general/metrics/metrics.sim create mode 100644 tests/script/general/metrics/testSuite.sim create mode 100644 tests/script/general/metrics/values.sim create mode 100644 tests/script/general/metrics/vnode3.sim create mode 100644 tests/script/general/parser/README.txt create mode 100644 tests/script/general/parser/alter.sim create mode 100644 tests/script/general/parser/alter1.sim create mode 100644 tests/script/general/parser/alter_stable.sim create mode 100644 tests/script/general/parser/auto_create_tb.sim create mode 100644 tests/script/general/parser/auto_create_tb_drop_tb.sim create mode 100644 tests/script/general/parser/binary_escapeCharacter.sim create mode 100644 tests/script/general/parser/bug.sim create mode 100644 tests/script/general/parser/col_arithmetic_operation.sim create mode 100644 tests/script/general/parser/columnValue.sim create mode 100644 tests/script/general/parser/columnValue_bigint.sim create mode 100644 tests/script/general/parser/columnValue_bool.sim create mode 100644 tests/script/general/parser/columnValue_double.sim create mode 100644 tests/script/general/parser/columnValue_float.sim create mode 100644 tests/script/general/parser/columnValue_int.sim create mode 100644 tests/script/general/parser/columnValue_smallint.sim create mode 100644 tests/script/general/parser/columnValue_tinyint.sim create mode 100644 tests/script/general/parser/commit.sim create mode 100644 tests/script/general/parser/create_db.sim create mode 100644 tests/script/general/parser/create_mt.sim create mode 100644 tests/script/general/parser/create_tb.sim create mode 100644 tests/script/general/parser/dbtbnameValidate.sim create mode 100644 tests/script/general/parser/fill.sim create mode 100644 tests/script/general/parser/fill_stb.sim create mode 100644 tests/script/general/parser/first_last.sim create mode 100644 tests/script/general/parser/first_last_query.sim create mode 100644 tests/script/general/parser/groupby.sim create mode 100644 tests/script/general/parser/import.sim create mode 100644 tests/script/general/parser/import_commit1.sim create mode 100644 tests/script/general/parser/import_commit2.sim create mode 100644 tests/script/general/parser/import_commit3.sim create mode 100644 tests/script/general/parser/import_file.sim create mode 100644 tests/script/general/parser/insert_multiTbl.sim create mode 100644 tests/script/general/parser/insert_tb.sim create mode 100644 tests/script/general/parser/interp.sim create mode 100644 tests/script/general/parser/interp_test.sim create mode 100644 tests/script/general/parser/join.sim create mode 100644 tests/script/general/parser/join_multivnode.sim create mode 100644 tests/script/general/parser/lastrow.sim create mode 100644 tests/script/general/parser/lastrow_query.sim create mode 100644 tests/script/general/parser/limit.sim create mode 100644 tests/script/general/parser/limit1.sim create mode 100644 tests/script/general/parser/limit1_stb.sim create mode 100644 tests/script/general/parser/limit1_tb.sim create mode 100644 tests/script/general/parser/limit1_tblocks100.sim create mode 100644 tests/script/general/parser/limit2.sim create mode 100644 tests/script/general/parser/limit2_query.sim create mode 100644 tests/script/general/parser/limit2_tblocks100.sim create mode 100644 tests/script/general/parser/limit_stb.sim create mode 100644 tests/script/general/parser/limit_tb.sim create mode 100644 tests/script/general/parser/mixed_blocks.sim create mode 100644 tests/script/general/parser/nchar.sim create mode 100644 tests/script/general/parser/null_char.sim create mode 100644 tests/script/general/parser/projection_limit_offset.sim create mode 100644 tests/script/general/parser/repeatAlter.sim create mode 100644 tests/script/general/parser/repeatStream.sim create mode 100644 tests/script/general/parser/selectResNum.sim create mode 100644 tests/script/general/parser/select_across_vnodes.sim create mode 100644 tests/script/general/parser/select_from_cache_disk.sim create mode 100644 tests/script/general/parser/select_with_tags.sim create mode 100644 tests/script/general/parser/set_tag_vals.sim create mode 100644 tests/script/general/parser/single_row_in_tb.sim create mode 100644 tests/script/general/parser/single_row_in_tb_query.sim create mode 100644 tests/script/general/parser/slimit.sim create mode 100644 tests/script/general/parser/slimit1.sim create mode 100644 tests/script/general/parser/slimit1_query.sim create mode 100644 tests/script/general/parser/slimit_alter_tags.sim create mode 100644 tests/script/general/parser/slimit_query.sim create mode 100644 tests/script/general/parser/stream.sim create mode 100644 tests/script/general/parser/stream_on_sys.sim create mode 100644 tests/script/general/parser/tags_dynamically_specifiy.sim create mode 100644 tests/script/general/parser/tags_filter.sim create mode 100644 tests/script/general/parser/tbnameIn.sim create mode 100644 tests/script/general/parser/tbnameIn_query.sim create mode 100644 tests/script/general/parser/testSuite.sim create mode 100644 tests/script/general/parser/timestamp.sim create mode 100644 tests/script/general/parser/timestamp_query.sim create mode 100644 tests/script/general/parser/where.sim create mode 100644 tests/script/general/stream/metrics_1.sim create mode 100644 tests/script/general/stream/metrics_del.sim create mode 100644 tests/script/general/stream/metrics_n.sim create mode 100644 tests/script/general/stream/metrics_replica1_vnoden.sim create mode 100644 tests/script/general/stream/stream_1.sim create mode 100644 tests/script/general/stream/stream_2.sim create mode 100644 tests/script/general/stream/stream_3.sim create mode 100644 tests/script/general/stream/stream_restart.sim create mode 100644 tests/script/general/stream/table_1.sim create mode 100644 tests/script/general/stream/table_del.sim create mode 100644 tests/script/general/stream/table_n.sim create mode 100644 tests/script/general/stream/table_replica1_vnoden.sim create mode 100644 tests/script/general/stream/testSuite.sim create mode 100644 tests/script/general/table/back_insert.sim create mode 100644 tests/script/general/table/bigint.sim create mode 100644 tests/script/general/table/binary.sim create mode 100644 tests/script/general/table/bool.sim create mode 100644 tests/script/general/table/column2.sim create mode 100644 tests/script/general/table/column_name.sim create mode 100644 tests/script/general/table/column_num.sim create mode 100644 tests/script/general/table/column_value.sim create mode 100644 tests/script/general/table/date.sim create mode 100644 tests/script/general/table/db.table.sim create mode 100644 tests/script/general/table/delete_reuse1.sim create mode 100644 tests/script/general/table/delete_reuse2.sim create mode 100644 tests/script/general/table/delete_writing.sim create mode 100644 tests/script/general/table/describe.sim create mode 100644 tests/script/general/table/double.sim create mode 100644 tests/script/general/table/float.sim create mode 100644 tests/script/general/table/int.sim create mode 100644 tests/script/general/table/limit.sim create mode 100644 tests/script/general/table/smallint.sim create mode 100644 tests/script/general/table/table.sim create mode 100644 tests/script/general/table/table_len.sim create mode 100644 tests/script/general/table/testSuite.sim create mode 100644 tests/script/general/table/tinyint.sim create mode 100644 tests/script/general/table/vgroup.sim create mode 100644 tests/script/general/tag/3.sim create mode 100644 tests/script/general/tag/4.sim create mode 100644 tests/script/general/tag/5.sim create mode 100644 tests/script/general/tag/6.sim create mode 100644 tests/script/general/tag/add.sim create mode 100644 tests/script/general/tag/bigint.sim create mode 100644 tests/script/general/tag/binary.sim create mode 100644 tests/script/general/tag/binary_binary.sim create mode 100644 tests/script/general/tag/bool.sim create mode 100644 tests/script/general/tag/bool_binary.sim create mode 100644 tests/script/general/tag/bool_int.sim create mode 100644 tests/script/general/tag/change.sim create mode 100644 tests/script/general/tag/column.sim create mode 100644 tests/script/general/tag/commit.sim create mode 100644 tests/script/general/tag/create.sim create mode 100644 tests/script/general/tag/delete.sim create mode 100644 tests/script/general/tag/double.sim create mode 100644 tests/script/general/tag/filter.sim create mode 100644 tests/script/general/tag/float.sim create mode 100644 tests/script/general/tag/int.sim create mode 100644 tests/script/general/tag/int_binary.sim create mode 100644 tests/script/general/tag/int_float.sim create mode 100644 tests/script/general/tag/set.sim create mode 100644 tests/script/general/tag/smallint.sim create mode 100644 tests/script/general/tag/testSuite.sim create mode 100644 tests/script/general/tag/tinyint.sim create mode 100644 tests/script/general/vector/metrics_field.sim create mode 100644 tests/script/general/vector/metrics_mix.sim create mode 100644 tests/script/general/vector/metrics_query.sim create mode 100644 tests/script/general/vector/metrics_tag.sim create mode 100644 tests/script/general/vector/metrics_time.sim create mode 100644 tests/script/general/vector/multi.sim create mode 100644 tests/script/general/vector/single.sim create mode 100644 tests/script/general/vector/table_field.sim create mode 100644 tests/script/general/vector/table_mix.sim create mode 100644 tests/script/general/vector/table_query.sim create mode 100644 tests/script/general/vector/table_time.sim create mode 100644 tests/script/general/vector/testSuite.sim create mode 100644 tests/script/unique/account/account_create.sim create mode 100644 tests/script/unique/account/account_delete.sim create mode 100644 tests/script/unique/account/account_len.sim create mode 100644 tests/script/unique/account/authority.sim create mode 100644 tests/script/unique/account/monitor.sim create mode 100644 tests/script/unique/account/pass_alter.sim create mode 100644 tests/script/unique/account/pass_len.sim create mode 100644 tests/script/unique/account/testSuite.sim create mode 100644 tests/script/unique/account/user_create.sim create mode 100644 tests/script/unique/account/user_len.sim create mode 100644 tests/script/unique/big/balance.sim create mode 100644 tests/script/unique/big/maxvnodes.sim create mode 100644 tests/script/unique/big/tcp.sim create mode 100644 tests/script/unique/big/testSuite.sim create mode 100644 tests/script/unique/cluster/backup/balance4.sim create mode 100644 tests/script/unique/cluster/backup/balance5.sim create mode 100644 tests/script/unique/cluster/backup/balancex.sim create mode 100644 tests/script/unique/cluster/balance1.sim create mode 100644 tests/script/unique/cluster/balance1_bug.sim create mode 100644 tests/script/unique/cluster/balance1_single.sim create mode 100644 tests/script/unique/cluster/balance2.sim create mode 100644 tests/script/unique/cluster/balance3.sim create mode 100644 tests/script/unique/cluster/testSuite.sim create mode 100644 tests/script/unique/column/replica3.sim create mode 100644 tests/script/unique/column/testSuite.sim create mode 100644 tests/script/unique/db/back_insert.sim create mode 100644 tests/script/unique/db/commit.sim create mode 100644 tests/script/unique/db/delete.sim create mode 100644 tests/script/unique/db/delete_part.sim create mode 100644 tests/script/unique/db/replica_add12.sim create mode 100644 tests/script/unique/db/replica_add13.sim create mode 100644 tests/script/unique/db/replica_add23.sim create mode 100644 tests/script/unique/db/replica_part.sim create mode 100644 tests/script/unique/db/replica_reduce21.sim create mode 100644 tests/script/unique/db/replica_reduce31.sim create mode 100644 tests/script/unique/db/replica_reduce32.sim create mode 100644 tests/script/unique/db/testSuite.sim create mode 100644 tests/script/unique/dnode/backup/balance4.sim create mode 100644 tests/script/unique/dnode/backup/balance5.sim create mode 100644 tests/script/unique/dnode/backup/unremove.sim create mode 100644 tests/script/unique/dnode/balance1.sim create mode 100644 tests/script/unique/dnode/balance2.sim create mode 100644 tests/script/unique/dnode/balance3.sim create mode 100644 tests/script/unique/dnode/balancex.sim create mode 100644 tests/script/unique/dnode/monitor_bug.sim create mode 100644 tests/script/unique/dnode/offline1.sim create mode 100644 tests/script/unique/dnode/offline2.sim create mode 100644 tests/script/unique/dnode/remove1.sim create mode 100644 tests/script/unique/dnode/remove2.sim create mode 100644 tests/script/unique/dnode/testSuite.sim create mode 100644 tests/script/unique/dnode/vnode_clean.sim create mode 100644 tests/script/unique/http/admin.sim create mode 100644 tests/script/unique/http/testSuite.sim create mode 100644 tests/script/unique/import/replica2.sim create mode 100644 tests/script/unique/import/replica3.sim create mode 100644 tests/script/unique/import/testSuite.sim create mode 100644 tests/script/unique/metrics/balance_replica1.sim create mode 100644 tests/script/unique/metrics/dnode2.sim create mode 100644 tests/script/unique/metrics/dnode2_stop.sim create mode 100644 tests/script/unique/metrics/dnode3.sim create mode 100644 tests/script/unique/metrics/replica2_dnode4.sim create mode 100644 tests/script/unique/metrics/replica2_vnode3.sim create mode 100644 tests/script/unique/metrics/replica3_dnode6.sim create mode 100644 tests/script/unique/metrics/replica3_vnode3.sim create mode 100644 tests/script/unique/metrics/testSuite.sim create mode 100644 tests/script/unique/mnode/backup/mgmt44.sim create mode 100644 tests/script/unique/mnode/backup/mgmt45.sim create mode 100644 tests/script/unique/mnode/backup/mgmt55.sim create mode 100644 tests/script/unique/mnode/backup/mgmt56.sim create mode 100644 tests/script/unique/mnode/backup/mgmt57.sim create mode 100644 tests/script/unique/mnode/drop.sim create mode 100644 tests/script/unique/mnode/mgmt22.sim create mode 100644 tests/script/unique/mnode/mgmt23.sim create mode 100644 tests/script/unique/mnode/mgmt24.sim create mode 100644 tests/script/unique/mnode/mgmt25.sim create mode 100644 tests/script/unique/mnode/mgmt26.sim create mode 100644 tests/script/unique/mnode/mgmt33.sim create mode 100644 tests/script/unique/mnode/mgmt34.sim create mode 100644 tests/script/unique/mnode/mgmtr1.sim create mode 100644 tests/script/unique/mnode/mgmtr2.sim create mode 100644 tests/script/unique/mnode/reuse.sim create mode 100644 tests/script/unique/mnode/secondIp.sim create mode 100644 tests/script/unique/mnode/tcp_mgmt22.sim create mode 100644 tests/script/unique/mnode/testSuite.sim create mode 100644 tests/script/unique/stream/metrics_balance.sim create mode 100644 tests/script/unique/stream/metrics_replica1_dnode2.sim create mode 100644 tests/script/unique/stream/metrics_replica2_dnode2.sim create mode 100644 tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim create mode 100644 tests/script/unique/stream/metrics_replica2_dnode3.sim create mode 100644 tests/script/unique/stream/metrics_replica3_dnode4.sim create mode 100644 tests/script/unique/stream/metrics_vnode_stop.sim create mode 100644 tests/script/unique/stream/table_balance.sim create mode 100644 tests/script/unique/stream/table_move.sim create mode 100644 tests/script/unique/stream/table_replica1_dnode2.sim create mode 100644 tests/script/unique/stream/table_replica2_dnode2.sim create mode 100644 tests/script/unique/stream/table_replica2_dnode2_vnoden.sim create mode 100644 tests/script/unique/stream/table_replica2_dnode3.sim create mode 100644 tests/script/unique/stream/table_replica3_dnode4.sim create mode 100644 tests/script/unique/stream/table_vnode_stop.sim create mode 100644 tests/script/unique/stream/testSuite.sim create mode 100644 tests/script/unique/table/back_insert.sim create mode 100644 tests/script/unique/table/delete_part.sim create mode 100644 tests/script/unique/table/testSuite.sim create mode 100644 tests/script/unique/vnode/back_insert.sim create mode 100644 tests/script/unique/vnode/back_insert_many.sim create mode 100644 tests/script/unique/vnode/backup/replica4.sim create mode 100644 tests/script/unique/vnode/backup/replica5.sim create mode 100644 tests/script/unique/vnode/commit.sim create mode 100644 tests/script/unique/vnode/many.sim create mode 100644 tests/script/unique/vnode/replica2_basic.sim create mode 100644 tests/script/unique/vnode/replica2_basic2.sim create mode 100644 tests/script/unique/vnode/replica2_repeat.sim create mode 100644 tests/script/unique/vnode/replica3_basic.sim create mode 100644 tests/script/unique/vnode/replica3_repeat.sim create mode 100644 tests/script/unique/vnode/replica3_vgroup.sim create mode 100644 tests/script/unique/vnode/testSuite.sim create mode 100644 tests/script/windows/account/authority.sim create mode 100644 tests/script/windows/account/user_create.sim create mode 100644 tests/script/windows/account/user_len.sim create mode 100644 tests/script/windows/alter/metrics.sim create mode 100644 tests/script/windows/alter/table.sim create mode 100644 tests/script/windows/compute/avg.sim create mode 100644 tests/script/windows/compute/bottom.sim create mode 100644 tests/script/windows/compute/count.sim create mode 100644 tests/script/windows/compute/diff.sim create mode 100644 tests/script/windows/compute/first.sim create mode 100644 tests/script/windows/compute/interval.sim create mode 100644 tests/script/windows/compute/last.sim create mode 100644 tests/script/windows/compute/leastsquare.sim create mode 100644 tests/script/windows/compute/max.sim create mode 100644 tests/script/windows/compute/min.sim create mode 100644 tests/script/windows/compute/percentile.sim create mode 100644 tests/script/windows/compute/stddev.sim create mode 100644 tests/script/windows/compute/sum.sim create mode 100644 tests/script/windows/compute/top.sim create mode 100644 tests/script/windows/db/basic.sim create mode 100644 tests/script/windows/db/len.sim create mode 100644 tests/script/windows/field/2.sim create mode 100644 tests/script/windows/field/3.sim create mode 100644 tests/script/windows/field/4.sim create mode 100644 tests/script/windows/field/5.sim create mode 100644 tests/script/windows/field/6.sim create mode 100644 tests/script/windows/field/bigint.sim create mode 100644 tests/script/windows/field/binary.sim create mode 100644 tests/script/windows/field/bool.sim create mode 100644 tests/script/windows/field/double.sim create mode 100644 tests/script/windows/field/float.sim create mode 100644 tests/script/windows/field/int.sim create mode 100644 tests/script/windows/field/single.sim create mode 100644 tests/script/windows/field/smallint.sim create mode 100644 tests/script/windows/field/tinyint.sim create mode 100644 tests/script/windows/import/basic.sim create mode 100644 tests/script/windows/insert/basic.sim create mode 100644 tests/script/windows/insert/query_block1_file.sim create mode 100644 tests/script/windows/insert/query_block1_memory.sim create mode 100644 tests/script/windows/insert/query_block2_file.sim create mode 100644 tests/script/windows/insert/query_block2_memory.sim create mode 100644 tests/script/windows/insert/query_file_memory.sim create mode 100644 tests/script/windows/insert/query_multi_file.sim create mode 100644 tests/script/windows/table/binary.sim create mode 100644 tests/script/windows/table/bool.sim create mode 100644 tests/script/windows/table/column_name.sim create mode 100644 tests/script/windows/table/column_num.sim create mode 100644 tests/script/windows/table/column_value.sim create mode 100644 tests/script/windows/table/db.table.sim create mode 100644 tests/script/windows/table/double.sim create mode 100644 tests/script/windows/table/float.sim create mode 100644 tests/script/windows/table/table.sim create mode 100644 tests/script/windows/table/table_len.sim create mode 100644 tests/script/windows/tag/3.sim create mode 100644 tests/script/windows/tag/4.sim create mode 100644 tests/script/windows/tag/5.sim create mode 100644 tests/script/windows/tag/6.sim create mode 100644 tests/script/windows/tag/add.sim create mode 100644 tests/script/windows/tag/bigint.sim create mode 100644 tests/script/windows/tag/binary.sim create mode 100644 tests/script/windows/tag/binary_binary.sim create mode 100644 tests/script/windows/tag/bool.sim create mode 100644 tests/script/windows/tag/bool_binary.sim create mode 100644 tests/script/windows/tag/bool_int.sim create mode 100644 tests/script/windows/tag/change.sim create mode 100644 tests/script/windows/tag/column.sim create mode 100644 tests/script/windows/tag/create.sim create mode 100644 tests/script/windows/tag/delete.sim create mode 100644 tests/script/windows/tag/double.sim create mode 100644 tests/script/windows/tag/filter.sim create mode 100644 tests/script/windows/tag/float.sim create mode 100644 tests/script/windows/tag/int.sim create mode 100644 tests/script/windows/tag/int_binary.sim create mode 100644 tests/script/windows/tag/int_float.sim create mode 100644 tests/script/windows/tag/set.sim create mode 100644 tests/script/windows/tag/smallint.sim create mode 100644 tests/script/windows/tag/tinyint.sim create mode 100644 tests/script/windows/testSuite.sim create mode 100644 tests/script/windows/vector/metrics_field.sim create mode 100644 tests/script/windows/vector/metrics_mix.sim create mode 100644 tests/script/windows/vector/metrics_query.sim create mode 100644 tests/script/windows/vector/metrics_tag.sim create mode 100644 tests/script/windows/vector/metrics_time.sim create mode 100644 tests/script/windows/vector/multi.sim create mode 100644 tests/script/windows/vector/single.sim create mode 100644 tests/script/windows/vector/table_field.sim create mode 100644 tests/script/windows/vector/table_mix.sim create mode 100644 tests/script/windows/vector/table_query.sim create mode 100644 tests/script/windows/vector/table_time.sim diff --git a/tests/script/general/account/monitor.sim b/tests/script/general/account/monitor.sim new file mode 100644 index 0000000000..d53ade2e4b --- /dev/null +++ b/tests/script/general/account/monitor.sim @@ -0,0 +1,36 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ========== step2 +sql drop database log -x step21 + return -1 +step21: +sql drop table log.cpu -x step22 + return -1 +step22: +sql drop user log -x step23 + return -1 +step23: + +print ========== step3 + +sleep 3000 +sql select * from log.dn +if $rows == 0 then + return -1 +endi + + + + diff --git a/tests/script/general/account/pass_alter.sim b/tests/script/general/account/pass_alter.sim new file mode 100644 index 0000000000..d815ca824f --- /dev/null +++ b/tests/script/general/account/pass_alter.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ============= step1 +sql create user read pass 'taosdata1' +sql create user write pass 'taosdata1' + +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata' + +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step2 +sql close +sql connect read +sleep 2000 +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata1' -x step2 + return -1 +step2: + + +print ============= step3 +sql close +sql connect write +sleep 2000 +sql alter user write pass 'taosdata' +sql alter user read pass 'taosdata' -x step3 + return -1 +step3: + +print ============= step4 +sql close +sql connect +sleep 2000 +sql create user oroot pass 'taosdata' +sql show users +if $rows != 6 then + return -1 +endi diff --git a/tests/script/general/account/pass_len.sim b/tests/script/general/account/pass_len.sim new file mode 100644 index 0000000000..5520ce6f17 --- /dev/null +++ b/tests/script/general/account/pass_len.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = apdb +$tbPrefix = aptb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$userPrefix = apusr + +print =============== step1 +$i = 0 +$user = $userPrefix . $i + +sql drop user $user -x step11 + return -1 +step11: + +sql create user $user PASS -x step12 + return -1 +step12: + +sql create user $user PASS 'taosdata' + +sql show users +if $rows != 4 then + return -1 +endi + +print =============== step2 +$i = 1 +$user = $userPrefix . $i +sql drop user $user -x step2 +step2: +sql create user $user PASS '1' +sql show users +if $rows != 5 then + return -1 +endi + +print =============== step3 +$i = 2 +$user = $userPrefix . $i +sql drop user $user -x step3 +step3: + +sql create user $user PASS 'abc0123456789' +sql show users +if $rows != 6 then + return -1 +endi + +print =============== step4 +$i = 3 +$user = $userPrefix . $i +sql create user $user PASS 'abcd012345678901234567891234567890' -x step4 + return -1 +step4: +sql show users +if $rows != 6 then + return -1 +endi + +$i = 0 +while $i < 3 + $user = $userPrefix . $i + sql drop user $user + $i = $i + 1 +endw + +sql show users +if $rows != 3 then + return -1 +endi + + diff --git a/tests/script/general/account/testSuite.sim b/tests/script/general/account/testSuite.sim new file mode 100644 index 0000000000..a66b4ac500 --- /dev/null +++ b/tests/script/general/account/testSuite.sim @@ -0,0 +1,5 @@ +run lite/account/pass_alter.sim +run lite/account/pass_len.sim +run lite/account/user_create.sim +run lite/account/user_len.sim +run lite/account/monitor.sim \ No newline at end of file diff --git a/tests/script/general/account/user_create.sim b/tests/script/general/account/user_create.sim new file mode 100644 index 0000000000..802b703118 --- /dev/null +++ b/tests/script/general/account/user_create.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sql show users +if $rows != 3 then + return -1 +endi + +sql create user read PASS 'pass123' +sql create user read PASS 'pass123' -x step1 + return -1 +step1: + +sql show users +if $rows != 4 then + return -1 +endi + +sql alter user read PASS 'taosdata' + +print =============== step2 +sql close +sql connect read +sleep 2000 + +sql alter user read PASS 'taosdata' + +print =============== step3 +sql drop user read -x step31 + return -1 +step31: +sql drop user sys -x step32 + return -1 +step32: +sql drop user stream -x step33 + return -1 +step33: + +print =============== step4 +sql close +sql connect +sleep 2000 + +sql alter user read privilege read +sql show users +if $data1_read != read then + return -1 +endi + +sql_error alter user read privilege super +sql show users +if $data1_read != read then + return -1 +endi + +sql alter user read privilege write +sql show users +if $data1_read != write then + return -1 +endi + +sql alter user read privilege 1 -x step43 + return -1 +step43: + +sql drop user sys -x step41 + return -1 +step41: + +sql drop user stream -x step42 + return -1 +step42: + +sql drop user read + + + + + diff --git a/tests/script/general/account/user_len.sim b/tests/script/general/account/user_len.sim new file mode 100644 index 0000000000..71198c61cb --- /dev/null +++ b/tests/script/general/account/user_len.sim @@ -0,0 +1,88 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_us_db +$tbPrefix = lm_us_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop user ac -x step0 + return -1 +step0: + +sql create user PASS '123' -x step1 + return -1 +step1: + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step2 +sql drop user a -x step2 +step2: +sql create user a PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step3 +sql drop user abc01234567890123456789 -x step3 +step3: + +sql create user abc01234567890123456789 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user abc01234567890123456789 +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step4 +sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 + return -1 +step4: +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5 +sql drop user 123 -x step5 +step5: +sql create user 123 PASS '123' -x step61 + return -1 +step61: + +sql create user a123 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a123 +sql show users +if $rows != 3 then + return -1 +endi diff --git a/tests/script/general/agg/fill.sim b/tests/script/general/agg/fill.sim new file mode 100644 index 0000000000..4056b9ef20 --- /dev/null +++ b/tests/script/general/agg/fill.sim @@ -0,0 +1,63 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =================== step1 +sql create database db +sql use db +sql create table mt (ts timestamp, k int, h binary(20), t bigint, s float, f double, x smallint, y tinyint, z bool) tags (a int, b binary(20), c bigint) +sql create table tb using mt tags (0, '1', 2) + +sql insert into tb values(now -200d, 200, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -100d, 100, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -30d, 30, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -20d, 20, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -10d, 10, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -5d, 5, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now -1d, 1, '1', 2, 3, 4, 5, 6, true); +sql insert into tb values(now, 0, '1', 2, 3, 4, 5, 6, true); + +sql select * from db.mt +if $rows != 8 then + return -1 +endi + +sql select * from db.tb +if $rows != 8 then + return -1 +endi + +sql select count(*) from db.mt +if $data00 != 8 then + return -1 +endi + +sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and ts>="2016-4-29 8:0:0" and ts < "2018-7-18 8:9:0" interval(1d) fill(value, 1) +sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and ts>="2016-4-29 8:0:0" and ts < "2018-7-18 8:9:0" interval(1d) fill(value, 1) + +print =================== step2 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =================== step3 +sql select * from db.mt +if $rows != 8 then + return -1 +endi + +sql select * from db.tb +if $rows != 8 then + return -1 +endi + +sql select count(*) from db.mt +if $data00 != 8 then + return -1 +endi diff --git a/tests/script/general/agg/stream.sim b/tests/script/general/agg/stream.sim new file mode 100644 index 0000000000..a024ad9b80 --- /dev/null +++ b/tests/script/general/agg/stream.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step2 +sql create database d4 precision 'us' +sql use d4 +sql create table t1 (ts timestamp, i int) +sql insert into d4.t1 values(now, 1) + +sql create table d4.s001 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s002 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s003 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s004 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s005 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s006 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s007 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s008 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s009 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s000 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s011 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s012 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s013 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s014 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s015 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s016 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s017 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s018 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s019 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s010 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s021 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s022 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s023 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s024 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s025 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s026 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s027 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s028 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s029 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s020 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s031 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s032 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s033 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s034 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s035 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s036 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s037 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s038 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s039 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s030 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s041 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s042 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s043 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s044 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s045 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s046 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s047 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s048 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s049 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s040 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s051 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s052 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s053 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s054 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s055 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s056 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s057 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s058 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s059 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s050 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s061 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s062 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s063 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s064 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s065 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s066 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s067 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s068 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s069 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s060 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s071 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s072 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s073 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s074 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s075 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s076 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s077 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s078 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s079 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s070 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s081 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s082 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s083 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s084 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s085 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s086 as select count(req_http), count(req_insert), avg(req_select), sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s087 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s088 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s089 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s080 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s091 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s092 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s093 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s094 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s095 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s096 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s097 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s098 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s099 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s090 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +print =============== step21 + +sql create table d4.s101 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s102 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s103 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s104 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s105 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s106 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s107 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s108 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s109 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s100 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s111 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s112 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s113 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s114 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s115 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s116 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s117 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s118 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s119 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s110 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s121 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s122 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s123 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s124 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s125 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s126 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s127 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s128 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s129 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s120 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s131 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s132 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s133 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s134 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s135 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s136 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s137 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s138 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s139 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s130 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s141 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s142 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s143 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s144 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s145 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s146 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s147 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s148 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s149 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s140 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s151 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s152 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s153 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s154 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s155 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s156 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s157 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s158 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s159 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s150 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s161 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s162 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s163 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s164 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s165 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s166 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s167 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s168 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s169 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s160 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s171 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s172 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s173 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s174 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s175 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s176 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s177 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s178 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s179 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s170 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s181 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s182 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s183 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s184 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s185 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s186 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s187 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s188 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s189 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s180 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + +sql create table d4.s191 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s192 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s193 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s194 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s195 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s196 as select count(req_http), count(req_insert) , sum(req_insert), max(req_select), min(req_insert) from log.dn_192_168_0_1 interval(5s) +sql create table d4.s197 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd) from log.dn interval(5s) +sql create table d4.s198 as select count(mem_taosd), count(mem_system), avg(mem_taosd), avg(mem_system), sum(mem_taosd), max(mem_taosd), min(mem_taosd) from log.dn interval(5s) +sql create table d4.s199 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used) from log.dn interval(5s) +sql create table d4.s190 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read) from log.dn interval(5s) + + +print =============== step3 +print sleep 22 seconds +sleep 50000 + +sql select * from d4.s001 +$s1 = $rows +print select * from d4.s001 ==> $s1 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s002 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s003 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s004 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s005 +$s5 = $rows +print select * from d4.s005 ==> $s5 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s006 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s007 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s008 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s009 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s010 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s101 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s102 +$s12 = $rows +print select * from d4.s102 ==> $s12 +if $rows <= 0 then + return -1 +endi diff --git a/tests/script/general/agg/testSuite.sim b/tests/script/general/agg/testSuite.sim new file mode 100644 index 0000000000..66d6dde565 --- /dev/null +++ b/tests/script/general/agg/testSuite.sim @@ -0,0 +1,2 @@ +run lite/agg/fill.sim +run lite/agg/stream.sim \ No newline at end of file diff --git a/tests/script/general/alter/cached_schema_after_alter.sim b/tests/script/general/alter/cached_schema_after_alter.sim new file mode 100644 index 0000000000..f9bac689fb --- /dev/null +++ b/tests/script/general/alter/cached_schema_after_alter.sim @@ -0,0 +1,119 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$db = csaa_db +$stb = csaastb +$tb1 = csaatb1 +$tb2 = csaatb2 + +$ts0 = 1537146000000 +$delta = 600000 +print ========== cached_schema_after_alter.sim + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db + +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +sql create table $tb1 using $stb tags( 1 ) +sql create table $tb2 using $stb tags( 2 ) + +sql_error alter table $tb1 add column c0 int +sql alter table $stb add column c2 int + +sql insert into $tb2 values ( $ts0 , 1, 1) +sql select * from $stb +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select * from $tb2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +sql use $db +sql select * from $stb +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select * from $tb2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +$ts = $ts0 + $delta +sql insert into $tb2 values ( $ts , 2, 2) +sql select * from $stb order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 2 then + return -1 +endi + +sql select * from $tb2 order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 2 then + return -1 +endi diff --git a/tests/script/general/alter/count.sim b/tests/script/general/alter/count.sim new file mode 100644 index 0000000000..be76aaa1c1 --- /dev/null +++ b/tests/script/general/alter/count.sim @@ -0,0 +1,266 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +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 + diff --git a/tests/script/general/alter/import.sim b/tests/script/general/alter/import.sim new file mode 100644 index 0000000000..0cf70c8549 --- /dev/null +++ b/tests/script/general/alter/import.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +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-30d, -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(ts timestamp, a int, b smallint) +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sql insert into tb values(now-22d, -24, 1) +sql insert into tb values(now-20d, -23, 2) +sql select count(b) from tb +if $data00 != 3 then + return -1 +endi + +print ========= step3 +sql import into tb values(now-23d, -23, 0) +sql import into tb values(now-21d, -21, 0) +sql select count(b) from tb +if $data00 != 5 then + return -1 +endi + +sql_error import into tb values(now-29d, -29, 0) +sql select count(b) from tb +if $data00 != 5 then + return -1 +endi diff --git a/tests/script/general/alter/insert1.sim b/tests/script/general/alter/insert1.sim new file mode 100644 index 0000000000..c58dce0203 --- /dev/null +++ b/tests/script/general/alter/insert1.sim @@ -0,0 +1,1150 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database d3 +sql use d3 +sql create table tb (ts timestamp, a int) +sql insert into tb values(now-28d, -28) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi + +print ======== step2 +sleep 2500 +sql alter table tb add column b smallint +sql insert into tb values(now-25d, -25, 0) +sleep 3000 +sql select * from tb order by ts desc +print $rows +if $rows != 2 then + return -1 +endi +if $data01 != -25 then + return -1 +endi +if $data11 != -28 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi + +print ======== step3 +sleep 2500 +sql alter table tb add column c tinyint +sql insert into tb values(now-22d, -22, 3, 0) +sleep 3000 +sql select * from tb order by ts asc +if $rows != 3 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi + +print ======== step4 +sleep 2500 +sql alter table tb add column d int +sql insert into tb values(now-19d, -19, 6, 3, 0) +sleep 3000 +sql select * from tb order by ts asc +if $rows != 4 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi + +print ======== step5 +sleep 2500 +sql alter table tb add column e bigint +sql insert into tb values(now-16d, -16, 9, 5, 4, 3) +sleep 3000 +sql select count(e) from tb +if $data00 != 1 then + return -1 +endi +sql select count(c) from tb +if $data00 != 3 then then + return -1 +endi +sql select * from tb order by ts asc +if $rows != 5 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi + +print ======== step6 +sleep 2500 +sql alter table tb add column f float +sql insert into tb values(now-13d, -13, 12, 11, 10, 9, 8) +sleep 3000 +sql select * from tb order by ts asc +if $rows != 6 then then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi + +print ======== step7 +sleep 2500 +sql alter table tb add column g double +sql insert into tb values(now-10d, -10, 15, 14, 13, 12, 11, 10) +sleep 3000 +sql select * from tb order by ts asc +if $rows != 7 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != null then + return -1 +endi + +print ======== step8 +sleep 2500 +sql alter table tb add column h binary(10) +sql insert into tb values(now-7d, -7, 18, 17, 16, 15, 14, 13, '11') +sleep 3000 +sql select * from tb order by ts asc +if $rows != 8 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != null then + return -1 +endi +if $data71 != -7 then + return -1 +endi +if $data72 != 18 then + return -1 +endi +if $data73 != 17 then + return -1 +endi +if $data74 != 16 then + return -1 +endi +if $data75 != 15 then + return -1 +endi +if $data76 != 14.00000 then + return -1 +endi +if $data77 != 13.000000000 then + return -1 +endi +if $data78 != 11 then + return -1 +endi +if $data79 != null then + return -1 +endi + +print ======== step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 + +sql select * from tb +if $rows != 8 then + return -1 +endi +if $data01 != -28 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -25 then + return -1 +endi +if $data12 != 0 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != -22 then + return -1 +endi +if $data22 != 3 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != 6 then + return -1 +endi +if $data33 != 3 then + return -1 +endi +if $data34 != 0 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != -16 then + return -1 +endi +if $data42 != 9 then + return -1 +endi +if $data43 != 5 then + return -1 +endi +if $data44 != 4 then + return -1 +endi +if $data45 != 3 then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != -13 then + return -1 +endi +if $data52 != 12 then + return -1 +endi +if $data53 != 11 then + return -1 +endi +if $data54 != 10 then + return -1 +endi +if $data55 != 9 then + return -1 +endi +if $data56 != 8.00000 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi +if $data61 != -10 then + return -1 +endi +if $data62 != 15 then + return -1 +endi +if $data63 != 14 then + return -1 +endi +if $data64 != 13 then + return -1 +endi +if $data65 != 12 then + return -1 +endi +if $data66 != 11.00000 then + return -1 +endi +if $data67 != 10.000000000 then + return -1 +endi +if $data68 != null then + return -1 +endi +if $data71 != -7 then + return -1 +endi +if $data72 != 18 then + return -1 +endi +if $data73 != 17 then + return -1 +endi +if $data74 != 16 then + return -1 +endi +if $data75 != 15 then + return -1 +endi +if $data76 != 14.00000 then + return -1 +endi +if $data77 != 13.000000000 then + return -1 +endi +if $data78 != 11 then + return -1 +endi diff --git a/tests/script/general/alter/insert2.sim b/tests/script/general/alter/insert2.sim new file mode 100644 index 0000000000..d749ddefb5 --- /dev/null +++ b/tests/script/general/alter/insert2.sim @@ -0,0 +1,683 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database d4 +sql use d4 +sql create table tb (ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10)) +sql insert into tb values(now-28d, 1, 2, 3, 4, 5, 6, 7, 8) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data03 != 3 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5 then + return -1 +endi +if $data06 != 6.00000 then + return -1 +endi +if $data07 != 7.000000000 then + return -1 +endi +if $data08 != 8 then + return -1 +endi + +print ======== step2 +sleep 2500 +sql_error alter table tb add column b smallint +sql_error alter table tb add column b int +sql alter table tb drop column b +sql insert into tb values(now-25d, 2, 3, 4, 5, 6, 7, 8) +sleep 3000 +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6.00000 then + return -1 +endi +if $data06 != 7.000000000 then + return -1 +endi +if $data07 != 8 then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 4 then + return -1 +endi +if $data14 != 5 then + return -1 +endi +if $data15 != 6.00000 then + return -1 +endi +if $data16 != 7.000000000 then + return -1 +endi +if $data17 != 8 then + return -1 +endi +if $data18 != null then + return -1 +endi + +print ======== step3 +sleep 2500 +sql alter table tb drop column c +sql insert into tb values(now-22d, 3, 4, 5, 6, 7, 8) +sleep 3000 +sql select * from tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi +if $data05 != 7.000000000 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 7.000000000 then + return -1 +endi +if $data16 != 8 then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 4 then + return -1 +endi +if $data23 != 5 then + return -1 +endi +if $data24 != 6.00000 then + return -1 +endi +if $data25 != 7.000000000 then + return -1 +endi +if $data26 != 8 then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi + +print ======== step4 +sleep 2500 +sql alter table tb drop column d +sql alter table tb drop column e +sql insert into tb values(now-19d, -19, 6, 3, 0) +sleep 3000 +sql select * from tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != -19 then + return -1 +endi +if $data02 != 6.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data12 != 6.00000 then + return -1 +endi +if $data13 != 7.000000000 then + return -1 +endi +if $data14 != 8 then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6.00000 then + return -1 +endi +if $data23 != 7.000000000 then + return -1 +endi +if $data24 != 8 then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 6.00000 then + return -1 +endi +if $data33 != 7.000000000 then + return -1 +endi +if $data34 != 8 then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi + +print ======== step5 +sleep 2500 +sql alter table tb drop column g +sql insert into tb values(now-16d, -16, 9, 5) +sleep 3000 +sql select count(f) from tb +if $data00 != 5 then + return -1 +endi +sql select * from tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != -16 then + return -1 +endi +if $data02 != 9.00000 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data11 != -19 then + return -1 +endi +if $data12 != 6.00000 then + return -1 +endi +if $data13 != 0 then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data22 != 6.00000 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data32 != 6.00000 then + return -1 +endi +if $data33 != 8 then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 6.00000 then + return -1 +endi +if $data43 != 8 then + return -1 +endi +if $data44 != null then + return -1 +endi +if $data45 != null then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi + +print ======== step6 +sleep 2500 +sql alter table tb drop column f +sql insert into tb values(now-13d, -13, 7) +sleep 3000 +sql select * from tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != -13 then + return -1 +endi +if $data11 != -16 then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +if $data08 != null then + return -1 +endi +if $data21 != -19 then + return -1 +endi +if $data22 != 0 then + return -1 +endi +if $data23 != null then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data32 != 8 then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data37 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data42 != 8 then + return -1 +endi +if $data43 != null then + return -1 +endi +if $data44 != null then + return -1 +endi +if $data45 != null then + return -1 +endi +if $data46 != null then + return -1 +endi +if $data47 != null then + return -1 +endi +if $data48 != null then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 8 then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data54 != null then + return -1 +endi +if $data55 != null then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data58 != null then + return -1 +endi + +print ======== step7 +sleep 2500 +sql alter table tb drop column h +sql insert into tb values(now-10d, -10) +sleep 3000 +sql select * from tb order by ts desc +if $rows != 7 then + return -1 +endi +print data01 = $data01 +if $data01 != -10 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data11 != -13 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data21 != -16 then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != null then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data41 != 3 then + return -1 +endi +if $data42 != null then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data52 != null then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != null then + return -1 +endi + +sql_error alter table tb drop column a + +print ======== step9 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 + +sql select * from tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != -10 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data11 != -13 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data21 != -16 then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data31 != -19 then + return -1 +endi +if $data32 != null then + return -1 +endi +if $data33 != null then + return -1 +endi +if $data41 != 3 then + return -1 +endi +if $data42 != null then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data52 != null then + return -1 +endi +if $data53 != null then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != null then + return -1 +endi + diff --git a/tests/script/general/alter/metrics.sim b/tests/script/general/alter/metrics.sim new file mode 100644 index 0000000000..a58d25c5be --- /dev/null +++ b/tests/script/general/alter/metrics.sim @@ -0,0 +1,783 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database d2 +sql use d2 +sql create table mt (ts timestamp, a int) TAGS (t int) +sql create table tb using mt tags (1) +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 * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi + +print ======== step2 +sql alter table mt add column b smallint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ======== step3 +sql alter table mt add column c tinyint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step4 +sql alter table mt add column d int +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step5 +sql alter table mt add column e bigint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step6 +sql alter table mt add column f float +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step7 +sql alter table mt add column g double +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step8 +sql alter table mt add column h binary(10) +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d2 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step11 +#sql alter table mt drop column a -x step111 +# return -1 +#step111: + +#sql alter table mt drop column ts -x step112 +# return -1 +#step112: + +#sql alter table mt drop column cdfg -x step113 +# return -1 +#step113: + +#sql alter table mt add column a -x step114 +# return -1 +#step114: + +#sql alter table mt add column b -x step115 +# return -1 +#step115: + +print ======== step12 +sql alter table mt drop column b +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step13 +sql alter table mt drop column c +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step14 +sql alter table mt drop column d +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step15 +sql alter table mt drop column e +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step16 +sql alter table mt drop column f +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step17 +sql alter table mt drop column g +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ============= step18 +sql alter table mt drop column h +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != null then + return -1 +endi + +print ======= over +sql drop database d2 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/alter/table.sim b/tests/script/general/alter/table.sim new file mode 100644 index 0000000000..6a0e62a0bf --- /dev/null +++ b/tests/script/general/alter/table.sim @@ -0,0 +1,686 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database d1 +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 * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi + +print ======== step3 +sql alter table tb add column c tinyint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi + +print ======== step4 +sql alter table tb add column d int +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step5 +sql alter table tb add column e bigint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi + +print ======== step6 +sql alter table tb add column f float +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi + +print ======== step7 +sql alter table tb add column g double +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi + +print ======== step8 +sql alter table tb add column h binary(10) +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d1 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step11 +sql alter table drop column a -x step111 + return -1 +step111: + +sql alter table drop column ts -x step112 + return -1 +step112: + +sql alter table drop column cdfg -x step113 + return -1 +step113: + +sql alter table add column a -x step114 + return -1 +step114: + +sql alter table add column b -x step115 + return -1 +step115: + +print ======== step12 +sql alter table tb drop column b +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi + +print ======== step13 +sql alter table tb drop column c +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi + +print ======== step14 +sql alter table tb drop column d +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi + +print ======== step15 +sql alter table tb drop column e +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi + +print ======== step16 +sql alter table tb drop column f +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi + +print ======== step17 +sql alter table tb drop column g +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi + +print ============= step18 +sql alter table tb drop column h +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != null then + return -1 +endi + +print ======= over +sql drop database d1 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/alter/testSuite.sim b/tests/script/general/alter/testSuite.sim new file mode 100644 index 0000000000..f27c871a4d --- /dev/null +++ b/tests/script/general/alter/testSuite.sim @@ -0,0 +1,7 @@ +run lite/alter/count.sim +run lite/alter/cached_schema_after_alter.sim +run lite/alter/import.sim +run lite/alter/insert1.sim +run lite/alter/insert2.sim +run lite/alter/metrics.sim +run lite/alter/table.sim \ No newline at end of file diff --git a/tests/script/general/cache/cache_balance.sim b/tests/script/general/cache/cache_balance.sim new file mode 100644 index 0000000000..1bc7d83e73 --- /dev/null +++ b/tests/script/general/cache/cache_balance.sim @@ -0,0 +1,58 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 2 +system sh/cfg.sh -n dnode2 -c httpMaxThreads -v 2 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c http -v 1 +system sh/cfg.sh -n dnode1 -c enableHttp -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c monitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode2 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode2 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 +system sh/cfg.sh -n dnode2 -c maxShellConns -v 30000 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database testdb +sql use testdb +sql create table meter1 (ts timestamp, val int) + +$x = 0 +$v = -100 +while $x < 30 + $v = $v + 1 + $ms = $v . m + sql insert into meter1 values (now $ms , $x ) + $x = $x + 1 +endw + +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +sleep 20000 +sql select * from log.dn_192_168_0_1 +print ===>rows $rows +print $data00 $data01 $data02 +print $data10 $data11 $data12 +print $data20 $data21 $data22 +if $rows < 20 then + return -1 +endi + +#sql create table sys.st as select avg(taosd), avg(system) from sys.cpu interval(30s) diff --git a/tests/script/general/cache/new_metrics.sim b/tests/script/general/cache/new_metrics.sim new file mode 100644 index 0000000000..6af54766b8 --- /dev/null +++ b/tests/script/general/cache/new_metrics.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = ca_nm_db +$tbPrefix = ca_nm_tb +$mtPrefix = ca_nm_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 10 +$rowNum = 20 + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 + +sql select * from $tb order by ts desc +print ===>rows $rows, data $data01 +if $rows != 20 then + return -1 +endi +if $data01 != 19 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 100 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select count(*) from $mt +print ===>rows $rows, data $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 100 then + return -1 +endi + +print =============== step3 + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 5 then + return -1 +endi + +print =============== step4 + +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ==> sleep 8 seconds to renew cache +sleep 8000 + +print =============== step5 + +sql select * from $tb order by ts desc +print ===>rows $rows, data $data01 +if $rows != 20 then + return -1 +endi +if $data01 != 19 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 200 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select count(*) from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data00 != 200 then + return -1 +endi + +print =============== step6 + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 10 then + return -1 +endi + + + + diff --git a/tests/script/general/cache/new_stream.sim b/tests/script/general/cache/new_stream.sim new file mode 100644 index 0000000000..38559cb936 --- /dev/null +++ b/tests/script/general/cache/new_stream.sim @@ -0,0 +1,108 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = ns_db +$tbPrefix = ns_tb +$mtPrefix = ns_mt +$stPrefix = ns_st +$tbNum = 5 +$rowNum = 200 +$totalNum = 200 + +print =============== step1 + +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix +$st = $stPrefix + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(10s) +print $data00 $data01 $data02 $data03 + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(10s) + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +print =============== step4 + +sql select * from $st +print $st ==> $rows1 $data00 $data01 $data02 $data03 +if $data13 >= 51 then + return -1 +endi + +print =============== step5 + +$tbNum = 10 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print =============== step6 +print sleep 22 seconds +sleep 22000 + +print =============== step7 + +sql select * from $st order by ts desc +print $st ==> $rows1 $data00 $data01 $data02 $data03 +if $data03 <= 51 then + return -1 +endi + + + + + diff --git a/tests/script/general/cache/restart_metrics.sim b/tests/script/general/cache/restart_metrics.sim new file mode 100644 index 0000000000..f4a607bf55 --- /dev/null +++ b/tests/script/general/cache/restart_metrics.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = ca_rm_db +$tbPrefix = ca_rm_tb +$mtPrefix = ca_rm_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(100)) +sql create table $tb using $mt tags( "1" ) +sql insert into $tb values (now, 1) + +sql select * from $tb +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step2 +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +print =============== step3 +print ==> sleep 8 seconds to renew cache +sleep 8000 + +print =============== step4 +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol int) +sql create table $tb using $mt tags( 3 ) +sql insert into $tb values (now, 2) + +sql select * from $tb +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi + diff --git a/tests/script/general/cache/restart_stream.sim b/tests/script/general/cache/restart_stream.sim new file mode 100644 index 0000000000..2f45f18737 --- /dev/null +++ b/tests/script/general/cache/restart_stream.sim @@ -0,0 +1,179 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 1 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = rs_db +$tbPrefix = rs_tb +$mtPrefix = rs_mt +$stPrefix = rs_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +$db = $dbPrefix +$tb = $tbPrefix . $i +$mt = $mtPrefix +$stm = $stPrefix . m +$stt = $stPrefix . t + +print =============== step1 +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, tbcol int, tbcol2 int ) TAGS(tgcol bool) +$i = 0 +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select count(*) from $mt interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 200 then + return -1 +endi + +print =============== step3 +sql create table $stt as select count(*) from $tb interval(1d) +sql create table $stm as select count(*) from $mt interval(1d) + +print sleep 22 seconds +sleep 22000 + +sql select * from $stt +print select count(*) from $stt ===> $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select * from $stm +print select * from $stm ===> $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 200 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 1 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 1 +system sh/exec.sh -n dnode1 -s start + +print =============== step5 +print ==> sleep 8 seconds to renew cache +sleep 8000 + + +print =============== step6 +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint, tbcol2 bigint ) TAGS(tgcol int) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + + +print =============== step7 + +sql select count(*) from $tb interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select count(*) from $mt interval(1d) +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi + +print =============== step8 +sql create table $stt as select count(*) from $tb interval(1d) +sql create table $stm as select count(*) from $mt interval(1d) + +print sleep 22 seconds +sleep 22000 + +sql select * from $stt +sleep 1000 +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 20 then + return -1 +endi + +sql select * from $stm +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi + + diff --git a/tests/script/general/cache/restart_table.sim b/tests/script/general/cache/restart_table.sim new file mode 100644 index 0000000000..d7c02116fd --- /dev/null +++ b/tests/script/general/cache/restart_table.sim @@ -0,0 +1,61 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$i = 0 +$dbPrefix = ca_rt_db +$tbPrefix = ca_rt_tb +$mtPrefix = ca_rt_mt +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed bool) +sql insert into $tb values (now, 1) +sql select * from $tb +print ===>rows $rows, data $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step2 +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 10 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 10 +system sh/exec.sh -n dnode1 -s start + +print =============== step3 +print ==> sleep 8 seconds to renew cache +sleep 3000 +sql reset query cache +sleep 18000 + +print =============== step4 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql insert into $tb values (now, 1) +sql select * from $tb +print ===>rows $rows, data $data01 +if $data01 != 1 then + return -1 +endi + + diff --git a/tests/script/general/cache/testSuite.sim b/tests/script/general/cache/testSuite.sim new file mode 100644 index 0000000000..c04b0b41f1 --- /dev/null +++ b/tests/script/general/cache/testSuite.sim @@ -0,0 +1,5 @@ +run lite/cache/restart_table.sim +run lite/cache/restart_metrics.sim +run lite/cache/restart_stream.sim +run lite/cache/new_metrics.sim +run lite/cache/new_stream.sim diff --git a/tests/script/general/column/commit.sim b/tests/script/general/column/commit.sim new file mode 100644 index 0000000000..3bc5d4e06a --- /dev/null +++ b/tests/script/general/column/commit.sim @@ -0,0 +1,154 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sql create database d3 +sql use d3 +sql create table d3.mt (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int) tags(a int, b smallint, c binary(20), d float, e double, f bigint) +sql create table d3.t1 using d3.mt tags(1, 2, '3', 4, 5, 6) + +sql show tables +if $rows != 1 then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d3.t1 values (now -300d,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d3.t1 values (now-200d,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d3.t1 values (now-150d,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d3.t1 values (now-100d,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d3.t1 values (now-50d,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d3.t1 values (now-20d,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d3.t1 values (now-10d,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d3.t1 values (now-1d,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d3.t1 values (now,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d3.t1 values (now+1d,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + + +print =============== step3 + +sql select * from d3.mt +if $rows != 10 then + return -1 +endi + +sql select * from d3.mt where c001 = 1 +if $rows != 1 then + return -1 +endi + +sql select * from d3.mt where c002 = 2 and c003 = 2 +if $rows != 1 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c235), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d3.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 4000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step5 + +sql select * from d3.mt +if $rows != 10 then + return -1 +endi + +sql select * from d3.mt where c001 = 1 +if $rows != 1 then + return -1 +endi + +sql select * from d3.mt where c002 = 2 and c003 = 2 +if $rows != 1 then + return -1 +endi + +sql select count(*) from d3.mt +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c128), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d3.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/column/metrics.sim b/tests/script/general/column/metrics.sim new file mode 100644 index 0000000000..94f5e6bb8a --- /dev/null +++ b/tests/script/general/column/metrics.sim @@ -0,0 +1,217 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sql create database d2 +sql use d2 +sql create table d2.mt (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int) tags(a int, b smallint, c binary(20), d float, e double, f bigint) +sql create table d2.t1 using d2.mt tags(1, 2, '3', 4, 5, 6) +sql create table d2.t2 using d2.mt tags(6, 7, '8', 9, 10, 11) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d2.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d2.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d2.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d2.t1 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d2.t1 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d2.t1 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d2.t1 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d2.t1 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d2.t1 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d2.t1 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +sql insert into d2.t2 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d2.t2 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d2.t2 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d2.t2 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d2.t2 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d2.t2 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d2.t2 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d2.t2 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d2.t2 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d2.t2 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +print =============== step3 + +sql select * from d2.mt +if $rows != 20 then + return -1 +endi + +sql select * from d2.mt where ts < now + 4m +if $rows != 10 then + return -1 +endi + +sql select * from d2.mt where c001 = 1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 and ts < now + 4m +if $rows != 2 then + return -1 +endi + +sql select count(*) from d2.mt +if $data00 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c235), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 20 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 90 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 20 then + return -1 +endi +if $data09 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c238), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt where a = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 10 then + return -1 +endi +if $data09 != 10 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +print =============== step5 + +sql select * from d2.mt +if $rows != 20 then + return -1 +endi + +sql select * from d2.mt where c001 = 1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.mt where c002 = 2 and c003 = 2 +if $rows != 2 then + return -1 +endi + +sql select count(*) from d2.mt +if $data00 != 20 then + return -1 +endi + +sql select count(c001), count(c248), avg(c001), avg(c248), sum(c001), max(c001), min(c248), avg(c128), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d2.mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data00 != 20 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 90 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 4.500000000 then + return -1 +endi +if $data08 != 20 then + return -1 +endi +if $data09 != 20 then + return -1 +endi diff --git a/tests/script/general/column/stream.sim b/tests/script/general/column/stream.sim new file mode 100644 index 0000000000..5ea04db04b --- /dev/null +++ b/tests/script/general/column/stream.sim @@ -0,0 +1,200 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sleep 2000 +sql select * from log.dn +if $rows == 0 then + return -1 +endi + +print =============== step2 +sql create database d4 precision 'us' +sql use d4 +sql create table t1 (ts timestamp, i int) +sql insert into d4.t1 values(now, 1) + +sql create table d4.s1 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), stddev(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s2 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), stddev(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s3 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used), stddev(disk_used), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s4 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read), stddev(io_write), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s5 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed), stddev(band_speed), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s6 as select count(req_http), count(req_insert), avg(req_http), avg(req_select), sum(req_insert), max(req_select), min(req_insert), stddev(req_select), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn_192_168_0_1 interval(5s) + +sql create table d4.s7 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s8 as select count(cpu_taosd), count(cpu_system), avg(cpu_taosd), avg(cpu_system), sum(cpu_taosd), max(cpu_taosd), min(cpu_taosd), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s9 as select count(disk_used), count(disk_total), avg(disk_used), avg(disk_total), sum(disk_used), max(disk_used), min(disk_used), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s10 as select count(io_read), count(io_write), avg(io_read), avg(io_write), sum(io_read), max(io_write), min(io_read), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s11 as select count(band_speed), avg(band_speed), sum(band_speed), max(band_speed), min(band_speed), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +sql create table d4.s12 as select count(req_http), count(req_insert), avg(req_select), avg(req_insert), sum(req_insert), max(req_select), min(req_insert), count(*) as c1, count(*) as c2, count(*) as c3, count(*) as c4, count(*) as c5, count(*) as c6, count(*) as c7, count(*) as c8, count(*) as c9, count(*) as c10, count(*) as c11, count(*) as c12, count(*) as c13, count(*) as c14, count(*) as c15, count(*) as c16, count(*) as c17, count(*) as c18, count(*) as c19, count(*) as c20, count(*) as c21, count(*) as c22, count(*) as c23, count(*) as c24, count(*) as c25, count(*) as c26, count(*) as c27, count(*) as c28, count(*) as c29, count(*) as c30 from log.dn interval(5s) + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +sql select * from d4.s1 +$s1 = $rows +print select * from d4.s1 ==> $s1 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s2 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s3 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s4 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s5 +$s5 = $rows +print select * from d4.s5 ==> $s5 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s6 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s7 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s8 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s9 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s10 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s11 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s12 +$s12 = $rows +print select * from d4.s12 ==> $s12 +if $rows <= 0 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +print sleep 22 seconds +sleep 22000 + +sql select * from d4.s1 +print select * from d4.s1 ==> $rows $s1 +if $rows <= 0 then + return -1 +endi +if $rows <= $s1 then + return -1 +endi + +sql select * from d4.s2 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s3 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s4 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s5 +print select * from d4.s5 ==> $rows $s5 +if $rows <= 0 then + return -1 +endi +if $rows <= $s5 then + return -1 +endi + + +sql select * from d4.s6 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s7 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s8 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s9 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s10 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s11 +if $rows <= 0 then + return -1 +endi + +sql select * from d4.s12 +print select * from d4.s12 ==> $rows $s12 +if $rows <= 0 then + return -1 +endi +if $rows <= $s12 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/column/table.sim b/tests/script/general/column/table.sim new file mode 100644 index 0000000000..85e11f43f4 --- /dev/null +++ b/tests/script/general/column/table.sim @@ -0,0 +1,213 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sql create database d1 +sql use d1 +sql create table d1.t1 (ts timestamp, c000 int, c001 int, c002 int, c003 int, c004 int, c005 int, c006 int, c007 int, c008 int, c009 int, c010 int, c011 int, c012 int, c013 int, c014 int, c015 int, c016 int, c017 int, c018 int, c019 int, c020 int, c021 int, c022 int, c023 int, c024 int, c025 int, c026 int, c027 int, c028 int, c029 int, c030 int, c031 int, c032 int, c033 int, c034 int, c035 int, c036 int, c037 int, c038 int, c039 int, c040 int, c041 int, c042 int, c043 int, c044 int, c045 int, c046 int, c047 int, c048 int, c049 int, c050 int, c051 int, c052 int, c053 int, c054 int, c055 int, c056 int, c057 int, c058 int, c059 int, c060 int, c061 int, c062 int, c063 int, c064 int, c065 int, c066 int, c067 int, c068 int, c069 int, c070 int, c071 int, c072 int, c073 int, c074 int, c075 int, c076 int, c077 int, c078 int, c079 int, c080 int, c081 int, c082 int, c083 int, c084 int, c085 int, c086 int, c087 int, c088 int, c089 int, c090 int, c091 int, c092 int, c093 int, c094 int, c095 int, c096 int, c097 int, c098 int, c099 int, c100 int, c101 int, c102 int, c103 int, c104 int, c105 int, c106 int, c107 int, c108 int, c109 int, c110 int, c111 int, c112 int, c113 int, c114 int, c115 int, c116 int, c117 int, c118 int, c119 int, c120 int, c121 int, c122 int, c123 int, c124 int, c125 int, c126 int, c127 int, c128 int, c129 int, c130 int, c131 int, c132 int, c133 int, c134 int, c135 int, c136 int, c137 int, c138 int, c139 int, c140 int, c141 int, c142 int, c143 int, c144 int, c145 int, c146 int, c147 int, c148 int, c149 int, c150 int, c151 int, c152 int, c153 int, c154 int, c155 int, c156 int, c157 int, c158 int, c159 int, c160 int, c161 int, c162 int, c163 int, c164 int, c165 int, c166 int, c167 int, c168 int, c169 int, c170 int, c171 int, c172 int, c173 int, c174 int, c175 int, c176 int, c177 int, c178 int, c179 int, c180 int, c181 int, c182 int, c183 int, c184 int, c185 int, c186 int, c187 int, c188 int, c189 int, c190 int, c191 int, c192 int, c193 int, c194 int, c195 int, c196 int, c197 int, c198 int, c199 int, c200 int, c201 int, c202 int, c203 int, c204 int, c205 int, c206 int, c207 int, c208 int, c209 int, c210 int, c211 int, c212 int, c213 int, c214 int, c215 int, c216 int, c217 int, c218 int, c219 int, c220 int, c221 int, c222 int, c223 int, c224 int, c225 int, c226 int, c227 int, c228 int, c229 int, c230 int, c231 int, c232 int, c233 int, c234 int, c235 int, c236 int, c237 int, c238 int, c239 int, c240 int, c241 int, c242 int, c243 int, c244 int, c245 int, c246 int, c247 int, c248 int, c249 int, c250 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step2 + +sql insert into d1.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) +sql insert into d1.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ) +sql insert into d1.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ) +sql insert into d1.t1 values (now+3m,3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) +sql insert into d1.t1 values (now+4m,4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ) +sql insert into d1.t1 values (now+5m,5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) + +sql insert into d1.t1 values (now+6m,6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 ) + +sql insert into d1.t1 values (now+7m,7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ) + +sql insert into d1.t1 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ) + +sql insert into d1.t1 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ) + +print ======= step3 + +sql select * from d1.t1 +print select * from d1.t1 => rows $rows +if $rows != 10 then + return -1 +endi + +sql select * from d1.t1 where ts < now + 4m +print select * from d1.t1 where ts < now + 4m => rows $rows +if $rows != 5 then + return -1 +endi + +sql select * from d1.t1 where c001 = 1 +print select * from d1.t1 where c001 = 1 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 +print select * from d1.t1 where c002 = 2 and c003 = 2 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 and ts < now + 4m +print select * from d1.t1 where c002 = 2 and c003 = 2 and ts < now + 4m => rows $rows +if $rows != 1 then + return -1 +endi + +sql select count(*) from d1.t1 +print select count(*) from d1.t1 => $data00 +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250) from d1.t1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d1.t1 + +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +print ============== step5 + +sql select * from d1.t1 +print select * from d1.t1 => rows $rows +if $rows != 10 then + return -1 +endi + +sql select * from d1.t1 where c001 = 1 +print select * from d1.t1 where c001 = 1 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select * from d1.t1 where c002 = 2 and c003 = 2 +print select * from d1.t1 where c002 = 2 and c003 = 2 => rows $rows +if $rows != 1 then + return -1 +endi + +sql select count(*) from d1.t1 +print select count(*) from d1.t1 => $data00 +if $data00 != 10 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250) from d1.t1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi + +sql select count(c001), count(c250), avg(c001), avg(c250), sum(c001), max(c001), min(c250), stddev(c250), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*), count(*) from d1.t1 +if $data00 != 10 then + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 45 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 2.872281323 then + return -1 +endi diff --git a/tests/script/general/column/testSuite.sim b/tests/script/general/column/testSuite.sim new file mode 100644 index 0000000000..64eba8cc7e --- /dev/null +++ b/tests/script/general/column/testSuite.sim @@ -0,0 +1,4 @@ +run lite/column/table.sim +run lite/column/metrics.sim +run lite/column/stream.sim +run lite/column/commit.sim diff --git a/tests/script/general/compress/commitlog.sim b/tests/script/general/compress/commitlog.sim new file mode 100644 index 0000000000..2323991044 --- /dev/null +++ b/tests/script/general/compress/commitlog.sim @@ -0,0 +1,128 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) -x step3 + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 20000 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + + diff --git a/tests/script/general/compress/compress.sim b/tests/script/general/compress/compress.sim new file mode 100644 index 0000000000..93e807e2db --- /dev/null +++ b/tests/script/general/compress/compress.sim @@ -0,0 +1,123 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + + diff --git a/tests/script/general/compress/compress2.sim b/tests/script/general/compress/compress2.sim new file mode 100644 index 0000000000..e0053648e2 --- /dev/null +++ b/tests/script/general/compress/compress2.sim @@ -0,0 +1,123 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/cfg.sh -n dnode1 -c compression -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + + diff --git a/tests/script/general/compress/testSuite.sim b/tests/script/general/compress/testSuite.sim new file mode 100644 index 0000000000..d0025636eb --- /dev/null +++ b/tests/script/general/compress/testSuite.sim @@ -0,0 +1,4 @@ +run lite/compress/compress.sim +run lite/compress/uncompress.sim +run lite/compress/commitlog.sim +run lite/compress/compress2.sim diff --git a/tests/script/general/compress/uncompress.sim b/tests/script/general/compress/uncompress.sim new file mode 100644 index 0000000000..13b19300ac --- /dev/null +++ b/tests/script/general/compress/uncompress.sim @@ -0,0 +1,123 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = cp_cp_db +$tbPrefix = cp_cp_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step2 +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step3 +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, f float, d double, str binary(256)) + +$count = 0 +while $count < $N + $ms = $count . a + sql insert into $tb values( now+ $ms , 1 , 0 , $count , $count , $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +print =============== step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +print =============== step5 + +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 1 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + +$i = 2 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql use $db +sql select * from $tb +print select * from $tb ==> $rows points +if $rows != $N then + return -1 +endi + + diff --git a/tests/script/general/compute/avg.sim b/tests/script/general/compute/avg.sim new file mode 100644 index 0000000000..9afdce8b14 --- /dev/null +++ b/tests/script/general/compute/avg.sim @@ -0,0 +1,156 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_av_db +$tbPrefix = m_av_tb +$mtPrefix = m_av_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select avg(tbcol) from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step3 +sql select avg(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +sql select avg(tbcol) as b from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step5 +sql select avg(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step6 +sql select avg(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select avg(tbcol) from $mt +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step8 +sql select avg(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step9 +sql select avg(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step10 +sql select avg(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select avg(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/bottom.sim b/tests/script/general/compute/bottom.sim new file mode 100644 index 0000000000..889191f468 --- /dev/null +++ b/tests/script/general/compute/bottom.sim @@ -0,0 +1,97 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_bo_db +$tbPrefix = m_bo_tb +$mtPrefix = m_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select bottom(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step3 +sql select bottom(tbcol, 1) from $tb where ts > now + 4m +print ===> $data01 +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select bottom(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql select bottom(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +print =============== step6 +sql select bottom(tbcol, 2) as b from $tb where ts > now + 4m +print ===> $data01 $data11 +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select bottom(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/count.sim b/tests/script/general/compute/count.sim new file mode 100644 index 0000000000..ead4a34a63 --- /dev/null +++ b/tests/script/general/compute/count.sim @@ -0,0 +1,172 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_co_db +$tbPrefix = m_co_tb +$mtPrefix = m_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + + +sql select count(*) from $tb +print ===> select count(*) from $tb => $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/diff.sim b/tests/script/general/compute/diff.sim new file mode 100644 index 0000000000..7581f6b4bd --- /dev/null +++ b/tests/script/general/compute/diff.sim @@ -0,0 +1,89 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(tbcol) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step3 +sql select diff(tbcol) from $tb where ts > now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select diff(tbcol) from $tb where ts < now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step4 +sql select diff(tbcol) as b from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step5 +sql select diff(tbcol) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select diff(tbcol) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim new file mode 100644 index 0000000000..2c831fc5a3 --- /dev/null +++ b/tests/script/general/compute/diff2.sim @@ -0,0 +1,155 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 2 +$rowNum = 10000 +$totalNum = 20000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $tinyint = $x / 128 + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $tinyint , $x , $x , $x , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(c1) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c2) from $tb +print ===> $data11 +if $data11 != 1.00000 then + return -1 +endi +sql select diff(c3) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c4) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c5) from $tb +print ===> $data11 +if $data11 != 0 then + return -1 +endi +sql select diff(c6) from $tb +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +sql_error select diff(c7) from $tb +sql_error select diff(c8) from $tb +sql_error select diff(c9) from $tb +sql_error select diff(ts) from $tb +sql_error select diff(c1), diff(c2) from $tb +sql_error select 2+diff(c1) from $tb +sql_error select diff(c1+2) from $tb +sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) +sql_error select diff(c1) from $mt +sql_error select diff(diff(c1)) from $tb +sql_error select diff(c1) from m_di_tb1 where c2 like '2%' + + +print =============== step3 +sql select diff(c1) from $tb where c1 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c2) from $tb where c2 > 5 +print ===> $data11 +if $data11 != 1.00000 then + return -1 +endi +sql select diff(c3) from $tb where c3 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c4) from $tb where c4 > 5 +print ===> $data11 +if $data11 != 1 then + return -1 +endi +sql select diff(c5) from $tb where c5 > 5 +print ===> $data11 +if $data11 != 0 then + return -1 +endi +sql select diff(c6) from $tb where c6 > 5 +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +print =============== step4 +sql select diff(c1) from $tb where c1 > 5 and c2 < $rowNum +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select diff(c1) from $tb where c9 like '%9' and c1 <= 20 +if $rows != 1 then + return -1 +endi +print ===> $data11 +if $data01 != 10 then + return -1 +endi + +print =============== step5 +sql select diff(c1) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select diff(c1) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi diff --git a/tests/script/general/compute/first.sim b/tests/script/general/compute/first.sim new file mode 100644 index 0000000000..9d98b61c1c --- /dev/null +++ b/tests/script/general/compute/first.sim @@ -0,0 +1,158 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_fi_db +$tbPrefix = m_fi_tb +$mtPrefix = m_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select first(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select first(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select first(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select first(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +sql select first(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select first(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select first(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select first(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select first(tbcol) as b from $mt interval(1m) +print select first(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select first(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select first(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select first(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/interval.sim b/tests/script/general/compute/interval.sim new file mode 100644 index 0000000000..36df589be9 --- /dev/null +++ b/tests/script/general/compute/interval.sim @@ -0,0 +1,174 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now + 4m interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now+1m interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now+1m interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/last.sim b/tests/script/general/compute/last.sim new file mode 100644 index 0000000000..ef851e973e --- /dev/null +++ b/tests/script/general/compute/last.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_la_db +$tbPrefix = m_la_tb +$mtPrefix = m_la_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select last(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select last(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select last(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select last(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select last(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select last(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select last(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select last(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select last(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select last(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/leastsquare.sim b/tests/script/general/compute/leastsquare.sim new file mode 100644 index 0000000000..1f9d7fa4a9 --- /dev/null +++ b/tests/script/general/compute/leastsquare.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_le_db +$tbPrefix = m_le_tb +$mtPrefix = m_le_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db keep 36500 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 2 + $ms = 1000 + while $x < $rowNum + $ms = $ms + 1000 + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select leastsquares(tbcol, 1, 1) from $tb +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step3 +sql select leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step4 +sql select leastsquares(tbcol, 1, 1) as b from $tb +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step5 +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi + +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step6 +sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/compute/max.sim b/tests/script/general/compute/max.sim new file mode 100644 index 0000000000..f8692c467f --- /dev/null +++ b/tests/script/general/compute/max.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_ma_db +$tbPrefix = m_ma_tb +$mtPrefix = m_ma_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select max(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select max(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select max(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select max(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select max(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select max(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select max(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select max(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select max(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select max(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/min.sim b/tests/script/general/compute/min.sim new file mode 100644 index 0000000000..5a3f4351d0 --- /dev/null +++ b/tests/script/general/compute/min.sim @@ -0,0 +1,158 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mi_db +$tbPrefix = m_mi_tb +$mtPrefix = m_mi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select min(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select min(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select min(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select min(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select min(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select min(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select min(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select min(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select min(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select min(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim new file mode 100644 index 0000000000..813d212636 --- /dev/null +++ b/tests/script/general/compute/null.sim @@ -0,0 +1,225 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + + $v1 = $x + $v2 = $x + if $x == 0 then + $v1 = NULL + endi + sql insert into $tb values (now + $ms , $v1 , $v2 ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select * from $tb +print $data00 $data01 $data02 +if $data01 != null then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $rows != 20 then + return -1 +endi + +print =============== step3 +sql select count(tbcol), count(tbcol2), avg(tbcol), avg(tbcol2), sum(tbcol), sum(tbcol2) from $tb +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 19 then + return -1 +endi +if $data01 != 20 then + return -1 +endi +if $data02 != 10.000000000 then + return -1 +endi +if $data03 != 9.500000000 then + return -1 +endi +if $data04 != 190 then + return -1 +endi +if $data05 != 190 then + return -1 +endi + +print =============== step4 +sql select * from $tb where tbcol2 = 19 +print ===> $data01 $data02 +if $rows != 1 then + return -1 +endi +if $data01 != 19 then + return -1 +endi +if $data02 != 19 then + return -1 +endi + +sql select * from $tb where tbcol = NULL -x step3 + return -1 +step3: + +print =============== step5 +sql create table $tb using $mt tags( NULL ) +# return -1 +#step51: + +#sql alter table $tb set tgcol=NULL -x step52 +# return -1 +#step52: + +sql select * from $mt where tgcol = NULL -x step5 + return -1 +step5: + +print =============== step6 +sql select count(tbcol), count(tbcol2), avg(tbcol), avg(tbcol2), sum(tbcol), sum(tbcol2) from $mt +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 190 then + return -1 +endi +if $data01 != 200 then + return -1 +endi +if $data02 != 10.000000000 then + return -1 +endi +if $data03 != 9.500000000 then + return -1 +endi +if $data04 != 1900 then + return -1 +endi +if $data05 != 1900 then + return -1 +endi + +print =============== step7 +sql create table t1 (ts timestamp, i bool) +sql create table t2 (ts timestamp, i smallint) +sql create table t3 (ts timestamp, i tinyint) +sql create table t4 (ts timestamp, i int) +sql create table t5 (ts timestamp, i bigint) +sql create table t6 (ts timestamp, i float) +sql create table t7 (ts timestamp, i double) +sql create table t8 (ts timestamp, i binary(10)) +sql insert into t1 values(now, NULL) +sql insert into t2 values(now, NULL) +sql insert into t3 values(now, NULL) +sql insert into t4 values(now, NULL) +sql insert into t5 values(now, NULL) +sql insert into t6 values(now, NULL) +sql insert into t7 values(now, NULL) +#sql insert into t8 values(now, NULL) + +#sql select * from t1 +#if $rows != 1 then +# return -1 +#endi +#if $data01 != NULL then +# return -1 +#endi + +sql select * from t2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql select * from t3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql select * from t4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql select * from t5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql select * from t6 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql select * from t7 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +#sql select * from t8 +#if $rows != 1 then +# return -1 +#endi +#if $data01 != null then +# return -1 +#endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/percentile.sim b/tests/script/general/compute/percentile.sim new file mode 100644 index 0000000000..2b30d4689c --- /dev/null +++ b/tests/script/general/compute/percentile.sim @@ -0,0 +1,114 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_pe_db +$tbPrefix = m_pe_tb +$mtPrefix = m_pe_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select percentile(tbcol, 10) from $tb +print ===> $data00 +if $data00 != 1.900000000 then + return -1 +endi + +sql select percentile(tbcol, 20) from $tb +print ===> $data00 +if $data00 != 3.800000000 then + return -1 +endi + +sql select percentile(tbcol, 100) from $tb +print ===> $data00 +if $data00 != 19.000000000 then + return -1 +endi + +sql select percentile(tbcol, 110) from $tb -x step2 + return -1 +step2: + +print =============== step3 +sql select percentile(tbcol, 1) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +print =============== step4 +sql select percentile(tbcol, 1) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/compute/stddev.sim b/tests/script/general/compute/stddev.sim new file mode 100644 index 0000000000..b39caea7a2 --- /dev/null +++ b/tests/script/general/compute/stddev.sim @@ -0,0 +1,96 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_st_db +$tbPrefix = m_st_tb +$mtPrefix = m_st_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select stddev(tbcol) from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step3 +sql select stddev(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.414213562 then + return -1 +endi + +print =============== step4 +sql select stddev(tbcol) as b from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step5 +sql select stddev(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi + +sql select stddev(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 5.766281297 then + return -1 +endi + +print =============== step6 +sql select stddev(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/sum.sim b/tests/script/general/compute/sum.sim new file mode 100644 index 0000000000..e298eabf44 --- /dev/null +++ b/tests/script/general/compute/sum.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_su_db +$tbPrefix = m_su_tb +$mtPrefix = m_su_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select sum(tbcol) from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step3 +sql select sum(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 10 then + return -1 +endi + +print =============== step4 +sql select sum(tbcol) as b from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step5 +sql select sum(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select sum(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 190 then + return -1 +endi + +print =============== step6 +sql select sum(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select sum(tbcol) from $mt +print ===> $data00 +if $data00 != 1900 then + return -1 +endi + +print =============== step8 +sql select sum(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 950 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select sum(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 < 5 then + return -1 +endi + +sql select sum(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 1900 then + return -1 +endi + +print =============== step10 +sql select sum(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $rows != 10 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/compute/testSuite.sim b/tests/script/general/compute/testSuite.sim new file mode 100644 index 0000000000..ad3afccdc6 --- /dev/null +++ b/tests/script/general/compute/testSuite.sim @@ -0,0 +1,16 @@ +run lite/compute/count.sim +run lite/compute/avg.sim +run lite/compute/sum.sim +run lite/compute/min.sim +run lite/compute/max.sim +run lite/compute/first.sim +run lite/compute/last.sim +run lite/compute/stddev.sim +run lite/compute/leastsquare.sim +run lite/compute/top.sim +run lite/compute/bottom.sim +run lite/compute/percentile.sim +run lite/compute/diff.sim +run lite/compute/interval.sim +run lite/compute/null.sim +run lite/compute/diff2.sim diff --git a/tests/script/general/compute/top.sim b/tests/script/general/compute/top.sim new file mode 100644 index 0000000000..d36f599b71 --- /dev/null +++ b/tests/script/general/compute/top.sim @@ -0,0 +1,97 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_to_db +$tbPrefix = m_to_tb +$mtPrefix = m_to_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select top(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step3 +sql select top(tbcol, 1) from $tb where ts < now + 4m +print ===> $data01 +if $data01 != 4 then + return -1 +endi + +print =============== step4 +sql select top(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step5 +sql select top(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 18 then + return -1 +endi +if $data11 != 19 then + return -1 +endi + +print =============== step6 +sql select top(tbcol, 2) as b from $tb where ts < now + 4m +print ===> $data01 $data11 +if $data01 != 3 then + return -1 +endi +if $data11 != 4 then + return -1 +endi + +sql select top(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/db/back_insert.sim b/tests/script/general/db/back_insert.sim new file mode 100644 index 0000000000..43831cca95 --- /dev/null +++ b/tests/script/general/db/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/general/db/backup/keep.sim b/tests/script/general/db/backup/keep.sim new file mode 100644 index 0000000000..c00665743c --- /dev/null +++ b/tests/script/general/db/backup/keep.sim @@ -0,0 +1,209 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========= start other dnodes +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step1 create db +sql create database keepdb replica 1 keep 30 days 7 +sql use keepdb +sql create table tb (ts timestamp, i int) + +$x = 1 +while $x < 41 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step2 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= 40 then + return -1 +endi +if $rows <= 20 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +$num1 = $rows + 40 + +print ======== step3 alter db +sql alter database keepdb keep 60 +sleep 1000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data02 != 1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 7 then + return -1 +endi +if $data06 != 60 then + return -1 +endi + +print ======== step4 insert data +$x = 41 +while $x < 81 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != $num1 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +print ======== step5 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= $num1 then + return -1 +endi +if $rows <= 50 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +print ======== step6 alter db +sql alter database keepdb keep 30 +sleep 1000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data02 != 1 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 7 then + return -1 +endi +if $data06 != 30 then + return -1 +endi + +print ======== step7 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows >= 40 then + return -1 +endi +if $rows <= 20 then + return -1 +endi +if $data01 != 80 then + return -1 +endi + +$num3 = $rows + 40 + +print ======== step8 insert data +$x = 81 +while $x < 121 + $time = $x . d + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +if $rows != $num3 then + return -1 +endi +if $data01 != 120 then + return -1 +endi + +print ======== step9 alter db +sql alter database keepdb keep -1 -x error1 + return -1 +error1: + +sql alter database keepdb keep 0 -x error2 + return -1 +error2: + +sql alter database keepdb days 1 -x error3 + return -1 +error3: + +print ======= test success + \ No newline at end of file diff --git a/tests/script/general/db/basic.sim b/tests/script/general/db/basic.sim new file mode 100644 index 0000000000..a3bd1ae505 --- /dev/null +++ b/tests/script/general/db/basic.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c tables -v 1000 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_db_db +$tbPrefix = ob_db_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db replica 1 days 20 keep 2000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 20 then + return -1 +endi +if $data07 != 1000 then + return -1 +endi + +print =============== step2 +sql create database $db +sql show databases +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql_error drop database $db + +print =============== step5 +sql create database $db replica 1 days 15 keep 1500 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 15 then + return -1 +endi + +#if $data06 != 1500,15000,1500 then +# return -1 +#endi +if $data07 != 1000 then + return -1 +endi + +print =============== step6 +sql use $db +sql create table $tb (ts timestamp, speed int) +$i = 1 +while $i < 4 + $db = $dbPrefix . $i + $tb = $tbPrefix . $i + sql create database $db + sql use $db + sql create table $tb (ts timestamp, speed int) + $i = $i + 1 +endw + +sql show databases +if $rows != 4 then + return -1 +endi + +$i = 4 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) -x step6 + return -1 +step6: + +print =============== step7 +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step9 +sql drop database $db + +print =============== step10 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step12 +sql drop database $db + +print =============== step13 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values (now+1a, 0) +sql insert into $tb values (now+2a, 1) +sql insert into $tb values (now+3a, 2) +sql insert into $tb values (now+4a, 3) +sql insert into $tb values (now+5a, 4) +sql select * from $tb +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql drop database $db + +print =============== step15 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step16 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql select * from $tb +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/db/delete_reuse1.sim b/tests/script/general/db/delete_reuse1.sim new file mode 100644 index 0000000000..55ed7a1f5c --- /dev/null +++ b/tests/script/general/db/delete_reuse1.sim @@ -0,0 +1,110 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop database d1 +sleep 1000 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql create database d1 replica 1 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +print ========= step4 +$x = 0 +while $x < 20 + + sql drop database d1 + sleep 1000 + sql insert into d1.t1 values(now, -1) -x step4 + return -1 + step4: + + sql create database d1 replica 1 + sql create table d1.t1 (ts timestamp, i int) + sql insert into d1.t1 values(now, $x ) + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + + $x = $x + 1 + + print ===> loop times: $x +endw diff --git a/tests/script/general/db/delete_reuse2.sim b/tests/script/general/db/delete_reuse2.sim new file mode 100644 index 0000000000..3014bd4d20 --- /dev/null +++ b/tests/script/general/db/delete_reuse2.sim @@ -0,0 +1,117 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop database d1 +sleep 1000 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql create database db1 replica 1 +sql create table db1.tb1 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 2) +sql select * from db1.tb1 +if $rows != 1 then + return -1 +endi + +print ========= step4 +$x = 1 +while $x < 20 + + $db = db . $x + $tb = tb . $x + sql use $db + sql drop database $db + + sleep 1000 + sql insert into $tb values(now, -1) -x step4 + return -1 + step4: + + $x = $x + 1 + $db = db . $x + $tb = tb . $x + + sql create database $db replica 1 + sql use $db + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + sql select * from $tb + if $rows != 1 then + return -1 + endi + + print ===> loop times: $x +endw diff --git a/tests/script/general/db/delete_reusevnode.sim b/tests/script/general/db/delete_reusevnode.sim new file mode 100644 index 0000000000..b8a268d5bb --- /dev/null +++ b/tests/script/general/db/delete_reusevnode.sim @@ -0,0 +1,121 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode2 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode3 -c cacheBlockSize -v 200 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print ======== step1 + +$tbPrefix = t +$i = 0 +while $i < 1000 + $db = db . $i + sql create database $db + sql use $db + + $tb = $tbPrefix . $i + sql create table $tb (ts timestamp, i int); + + sql insert into $tb values(now, 1); + + sleep 1000 + sql drop database $db + + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode2 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode3 -c cacheBlockSize -v 200 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print ======== step1 + +$tbPrefix = t +$i = 0 +while $i < 1000 + $db = db . $i + sql create database $db tables 4 + sql use $db + + sql create table st (ts timesetamp, i int) tags(j int); + $tb = $tbPrefix . $i + $tb = $tb . a + + $tb1 = $tb . 1 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 2 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 3 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 6 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 7 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 8 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + sleep 1000 + sql drop database $db + + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/db/delete_reusevnode2.sim b/tests/script/general/db/delete_reusevnode2.sim new file mode 100644 index 0000000000..f261b3d1e2 --- /dev/null +++ b/tests/script/general/db/delete_reusevnode2.sim @@ -0,0 +1,79 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode2 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode3 -c cacheBlockSize -v 200 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 3000 + +print ======== step1 + + +sql create database db tables 4; +sql use db + + +$tbPrefix = t +$i = 0 +while $i < 1000 + + + sql create table st (ts timestamp, i int) tags(j int); + $tb = $tbPrefix . $i + $tb = $tb . a + + $tb1 = $tb . 1 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 2 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 3 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 5 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 6 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 7 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + $tb1 = $tb . 8 + sql create table $tb1 using st tags(1) + sql insert into $tb1 values(now, 1); + + sql drop table st + + sleep 1000 + print times $i + $i = $i + 1 + +endw + +print ======== step2 +sleep 1000 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/db/delete_writing1.sim b/tests/script/general/db/delete_writing1.sim new file mode 100644 index 0000000000..e06371266f --- /dev/null +++ b/tests/script/general/db/delete_writing1.sim @@ -0,0 +1,59 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +print ======== start back +run_back lite/db/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 20 + + print drop database times $x + sql drop database db -x step1 + step1: + + sql create database db + sql create table db.tb (ts timestamp, i int) + + sleep 3000 + + $x = $x + 1 +endw diff --git a/tests/script/general/db/delete_writing2.sim b/tests/script/general/db/delete_writing2.sim new file mode 100644 index 0000000000..751cc26b2f --- /dev/null +++ b/tests/script/general/db/delete_writing2.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +sql create database db2 +sql create table db2.tb2 (ts timestamp, i int) +sql insert into db2.tb2 values(now, 1) + +sql create database db3 +sql create table db3.tb3 (ts timestamp, i int) +sql insert into db3.tb3 values(now, 1) + +sql create database db4 +sql create table db4.tb4 (ts timestamp, i int) +sql insert into db4.tb4 values(now, 1) + +print ======== start back +run_back lite/db/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 10 + + print drop database times $x + sql drop database db -x step1 + step1: + + sql create database db + sql create table db.tb (ts timestamp, i int) + + sleep 3000 + + $x = $x + 1 +endw diff --git a/tests/script/general/db/len.sim b/tests/script/general/db/len.sim new file mode 100644 index 0000000000..5e4a891dc2 --- /dev/null +++ b/tests/script/general/db/len.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== step1 +sql_error drop database dd + +sql create database -x step1 + return -1 +step1: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create database a +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create database a12345678 +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a12345678 +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create database a012345678901201234567890120123456789012 -x step4 + return -1 +step4: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create database a;1 +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create database a'1 -x step6 + return -1 +step6: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create database (a) -x step7 + return -1 +step7: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create database a.1 -x step8 + return -1 +step8: +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/db/repeat.sim b/tests/script/general/db/repeat.sim new file mode 100644 index 0000000000..e008d95377 --- /dev/null +++ b/tests/script/general/db/repeat.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c tables -v 4 + +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +sql create database d1 +sql create table d1.t1(ts timestamp, i int) + +sql create database d2 +sql create table d2.t1(ts timestamp, i int) + +sql create database d3 +sql create table d3.t1(ts timestamp, i int) + +sql create database d4 +sql create table d4.t1(ts timestamp, i int) + +sleep 3000 + +sql drop database d1 +sql drop database d2 +sql drop database d3 +sql drop database d4 +sleep 3000 + +sql create database d5 +sql create table d5.t1(ts timestamp, i int) + +sql create database d6 +sql create table d6.t1(ts timestamp, i int) + +sql create database d7 +sql create table d7.t1(ts timestamp, i int) + +sql create database d8 +sql create table d8.t1(ts timestamp, i int) + +sleep 3000 + +sql drop database d5 +sql drop database d6 +sql drop database d7 +sql drop database d8 + +sleep 3000 + +sql create database d9; +sql create table d9.t1(ts timestamp, i int) + +sql create database d10; +sql create table d10.t1(ts timestamp, i int) + +sql create database d11 +sql create table d11.t1(ts timestamp, i int) + +sql create database d12 +sql create table d12.t1(ts timestamp, i int) + +sql drop database d9 +sql drop database d10 +sql drop database d11 +sql drop database d12 diff --git a/tests/script/general/db/tables.sim b/tests/script/general/db/tables.sim new file mode 100644 index 0000000000..aed8621116 --- /dev/null +++ b/tests/script/general/db/tables.sim @@ -0,0 +1,126 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== step2 +sql create database db tables 2 +sql show databases +print $rows $data07 + +if $rows != 1 then + return -1 +endi + +if $data07 != 2 then + return -1 +endi + +print =============== step3 +sql use db +sql create table t1 (ts timestamp, i int) +sql create table t2 (ts timestamp, i int) +sql create table t3 (ts timestamp, i int) +sql create table t4 (ts timestamp, i int) +sql create table t11 (ts timestamp, i int) +sql create table t22 (ts timestamp, i int) +sql create table t33 (ts timestamp, i int) +sql create table t44 (ts timestamp, i int) + +print =============== step4 +sql insert into t1 values(now, 1) +sql insert into t2 values(now, 2) +sql insert into t3 values(now, 3) +sql insert into t4 values(now, 4) +sql insert into t11 values(now, 1) +sql insert into t22 values(now, 2) +sql insert into t33 values(now, 3) +sql insert into t44 values(now, 4) + +print =============== step5 +sql select * from t1 +if $data01 != 1 then + return -1 +endi + +sql select * from t2 +if $data01 != 2 then + return -1 +endi + +sql select * from t3 +if $data01 != 3 then + return -1 +endi + +sql select * from t4 +if $data01 != 4 then + return -1 +endi + +print =============== step6 +sql drop database db +sql reset query cache +sleep 20000 + +print =============== step7 +sql create database db tables 2 +sql show databases +print $rows $data07 + +if $rows != 1 then + return -1 +endi + +if $data07 != 2 then + return -1 +endi + +print =============== step8 +sql use db +sql create table t1 (ts timestamp, i int) +sql create table t2 (ts timestamp, i int) +sql create table t3 (ts timestamp, i int) +sql create table t4 (ts timestamp, i int) +sql create table t11 (ts timestamp, i int) +sql create table t22 (ts timestamp, i int) +sql create table t33 (ts timestamp, i int) +sql create table t44 (ts timestamp, i int) + +print =============== step9 +sql insert into t1 values(now, 1) +sql insert into t2 values(now, 2) +sql insert into t3 values(now, 3) +sql insert into t4 values(now, 4) +sql insert into t11 values(now, 1) +sql insert into t22 values(now, 2) +sql insert into t33 values(now, 3) +sql insert into t44 values(now, 4) + +print =============== step10 +sql select * from t1 +if $data01 != 1 then + return -1 +endi + +sql select * from t2 +if $data01 != 2 then + return -1 +endi + +sql select * from t3 +if $data01 != 3 then + return -1 +endi + +sql select * from t4 +if $data01 != 4 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/db/testSuite.sim b/tests/script/general/db/testSuite.sim new file mode 100644 index 0000000000..49a2c4eba8 --- /dev/null +++ b/tests/script/general/db/testSuite.sim @@ -0,0 +1,7 @@ +run lite/db/tables.sim +run lite/db/basic.sim +run lite/db/len.sim +run lite/db/delete_reuse1.sim +run lite/db/delete_reuse2.sim +run lite/db/delete_writing1.sim +run lite/db/delete_writing2.sim diff --git a/tests/script/general/field/2.sim b/tests/script/general/field/2.sim new file mode 100644 index 0000000000..c2d9d78085 --- /dev/null +++ b/tests/script/general/field/2.sim @@ -0,0 +1,295 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_bt_db +$tbPrefix = fi_bt_tb +$mtPrefix = fi_bt_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol2 bool, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol order by tgcol desc +print $db +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/3.sim b/tests/script/general/field/3.sim new file mode 100644 index 0000000000..13f4c14f7b --- /dev/null +++ b/tests/script/general/field/3.sim @@ -0,0 +1,521 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_3_db +$tbPrefix = fi_3_tb +$mtPrefix = fi_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 int, tbcol3 float) TAGS(tgcol1 smallint, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/4.sim b/tests/script/general/field/4.sim new file mode 100644 index 0000000000..aa8fb822a4 --- /dev/null +++ b/tests/script/general/field/4.sim @@ -0,0 +1,711 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_4_db +$tbPrefix = fi_4_tb +$mtPrefix = fi_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 float, tbcol4 double) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/5.sim b/tests/script/general/field/5.sim new file mode 100644 index 0000000000..9fa08cb799 --- /dev/null +++ b/tests/script/general/field/5.sim @@ -0,0 +1,834 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_5_db +$tbPrefix = fi_5_tb +$mtPrefix = fi_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 tinyint, tbcol2 int, tbcol3 bigint, tbcol4 double, tbcol5 smallint) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/6.sim b/tests/script/general/field/6.sim new file mode 100644 index 0000000000..b2ced5b9df --- /dev/null +++ b/tests/script/general/field/6.sim @@ -0,0 +1,989 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_6_db +$tbPrefix = fi_6_tb +$mtPrefix = fi_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 smallint, tbcol4 bigint, tbcol5 float, tbcol6 bool) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 float, tgcol6 bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tbcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 interval(1d) group by tgcol6 order by tgcol6 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/bigint.sim b/tests/script/general/field/bigint.sim new file mode 100644 index 0000000000..2093f55de5 --- /dev/null +++ b/tests/script/general/field/bigint.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_bi_db +$tbPrefix = fi_bi_tb +$mtPrefix = fi_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/binary.sim b/tests/script/general/field/binary.sim new file mode 100644 index 0000000000..a49af37806 --- /dev/null +++ b/tests/script/general/field/binary.sim @@ -0,0 +1,84 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_by_db +$tbPrefix = fi_by_tb +$mtPrefix = fi_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol binary(10)) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '0' ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '1' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + + +print =============== step2 + +sql select * from $mt where tbcol = '0' +if $rows != 100 then + return -1 +endi + +sql select * from $mt where ts > now + 4m and tbcol = '1' +if $rows != 75 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol -x step13 + return -1 +step13: + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol -x step14 + return -1 +step14: + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol -x step15 + return -1 +step15: + +#can't filter binary fields + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/bool.sim b/tests/script/general/field/bool.sim new file mode 100644 index 0000000000..aa70dbd23e --- /dev/null +++ b/tests/script/general/field/bool.sim @@ -0,0 +1,161 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_bo_db +$tbPrefix = fi_bo_tb +$mtPrefix = fi_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/double.sim b/tests/script/general/field/double.sim new file mode 100644 index 0000000000..daca74fcde --- /dev/null +++ b/tests/script/general/field/double.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_do_db +$tbPrefix = fi_do_tb +$mtPrefix = fi_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol double) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/float.sim b/tests/script/general/field/float.sim new file mode 100644 index 0000000000..8bdebd6714 --- /dev/null +++ b/tests/script/general/field/float.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_fl_db +$tbPrefix = fi_fl_tb +$mtPrefix = fi_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol float) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/int.sim b/tests/script/general/field/int.sim new file mode 100644 index 0000000000..a3d4c901eb --- /dev/null +++ b/tests/script/general/field/int.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/single.sim b/tests/script/general/field/single.sim new file mode 100644 index 0000000000..ad844da95d --- /dev/null +++ b/tests/script/general/field/single.sim @@ -0,0 +1,218 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_si_db +$tbPrefix = fi_si_tb +$mtPrefix = fi_si_mt +$rowNum = 20 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, tbcol int) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + +print =============== step2 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +sql select * from $tb where tbcol = 10 +if $rows != 1 then + return -1 +endi +if $data01 != 10 then + return -1 +endi + +sql select * from $tb where tbcol = 8 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where tbcol < 10 +if $rows != 10 then + return -1 +endi +if $data91 != 9 then + return -1 +endi + +sql select * from $tb where tbcol <= 10 +if $rows != 11 then + return -1 +endi +if $data81 != 8 then + return -1 +endi + +sql select * from $tb where tbcol > 10 +if $rows != 9 then + return -1 +endi +if $data81 != 19 then + return -1 +endi + +sql select * from $tb where tbcol > 10 order by ts asc +if $rows != 9 then + return -1 +endi +if $data01 != 11 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data31 != 6 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts asc +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +sql select * from $tb where tbcol > 10 and tbcol < 5 order by ts asc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi + +sql select * from $tb where tbcol = 10 and ts < now + 4m +print select * from $tb where tbcol = 10 and ts < now + 4m +if $rows != 0 then + return -1 +endi + +sql select * from $tb where tbcol = 4 and ts < now + 4m order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts < now + 4m order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m order by ts desc +print $rows $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select count(*) from $tb +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from $tb where tbcol = 10 +if $data00 != 1 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 8 or tbcol = 9 +#if $data00 != 2 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol < 10 +if $data00 != 10 then + return -1 +endi + +sql select count(*) from $tb where tbcol <= 10 +if $data00 != 11 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 +if $data00 != 4 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 order by ts asc -x step4 +# return -1 +step4: + +print =============== step5 +sql select count(*) from $tb where ts < now + 4m +if $data00 != 5 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 10 and ts < now + 4m +#if $data00 != 0 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol = 4 and ts < now + 4m +if $data00 != 1 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts < now + 4m +if $data00 != 5 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m +if $data00 != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/smallint.sim b/tests/script/general/field/smallint.sim new file mode 100644 index 0000000000..432d766ac2 --- /dev/null +++ b/tests/script/general/field/smallint.sim @@ -0,0 +1,160 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_sm_db +$tbPrefix = fi_sm_tb +$mtPrefix = fi_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol smallint) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/field/testSuite.sim b/tests/script/general/field/testSuite.sim new file mode 100644 index 0000000000..5b086df883 --- /dev/null +++ b/tests/script/general/field/testSuite.sim @@ -0,0 +1,14 @@ +run lite/field/single.sim +run lite/field/bool.sim +run lite/field/smallint.sim +run lite/field/tinyint.sim +run lite/field/int.sim +run lite/field/bigint.sim +run lite/field/float.sim +run lite/field/double.sim +run lite/field/binary.sim +run lite/field/2.sim +run lite/field/3.sim +run lite/field/4.sim +run lite/field/5.sim +run lite/field/6.sim \ No newline at end of file diff --git a/tests/script/general/field/tinyint.sim b/tests/script/general/field/tinyint.sim new file mode 100644 index 0000000000..9b143e061f --- /dev/null +++ b/tests/script/general/field/tinyint.sim @@ -0,0 +1,161 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = fi_ti_db +$tbPrefix = fi_ti_tb +$mtPrefix = fi_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol tinyint) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/http/bug.go b/tests/script/general/http/bug.go new file mode 100644 index 0000000000..61991f4d02 --- /dev/null +++ b/tests/script/general/http/bug.go @@ -0,0 +1,329 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + + for j := 0; j < config.DataNum; j++ { + for i := 0; i < config.TablePerConn; i++ { + tmVal := int64(j)*int64(config.DataInterval) + tmStart + 1 + tbIndex := i + tbStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("import into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + exec(client, sql) + time.Sleep(time.Millisecond * time.Duration(10)) + } + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + + tbStart := conn*config.TablePerConn + config.TableStart + for j := 0; j < config.DataNum; j++ { + tbIndex := 0 + tbStart + sql := fmt.Sprintf("select max(i),min(i) from db.mt where tbname in ('%s%d'", config.TablePrefix, tbIndex) + for i := 1; i < 2000; i++ { + tbIndex := i + tbStart + sql += fmt.Sprintf(",'%s%d'", config.TablePrefix, tbIndex) + } + sql += ") group by orgno" + + //sql := fmt.Sprintf("select count(*) from db.mt") + //sql := fmt.Sprintf("select max(i),min(i) from db.mt", config.TablePrefix, tbIndex) + + exec(client, sql) + time.Sleep(time.Millisecond * time.Duration(10)) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + fmt.Println("\n================select data ========================") + + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + wg.Wait() + + fmt.Println("\n================http test stop ======================") +} diff --git a/tests/script/general/http/grafana.sim b/tests/script/general/http/grafana.sim new file mode 100644 index 0000000000..818114f9d7 --- /dev/null +++ b/tests/script/general/http/grafana.sim @@ -0,0 +1,182 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data + +sql create database d1 +sql use d1 +sql create table table_gc (ts timestamp, db binary(10), tb binary(20), col binary(20)) +sql create table m1 (ts timestamp, v1 int, v2 float) +sql create table m2 (ts timestamp, v1 int, v2 float) + +sql insert into table_gc values('2017-12-25 21:28:41.022', 'd1', 'm1', 'v1') +sql insert into table_gc values('2017-12-25 21:28:42.022', 'd1', 'm1', 'v2') +sql insert into table_gc values('2017-12-25 21:28:43.022', 'd1', 'm2', 'v1') +sql insert into table_gc values('2017-12-25 21:28:44.022', 'd1', 'm2', 'v2') + +sql insert into m1 values(1514208523020, 1, 4.1) +sql insert into m1 values(1514208523021, 2, 5.1) +sql insert into m1 values(1514208523022, 3, 6.1) + +sql insert into m2 values(1514208523024, 3, 6.1) +sql insert into m2 values(1514208523025, 2, 5.1) +sql insert into m2 values(1514208523026, 1, 4.1) + +sql create table mt (ts timestamp, i int) tags(a int, b binary(10)) +sql create table t1 using mt tags (1, 'a') +sql create table t2 using mt tags (2, 'b') +sql create table t3 using mt tags (3, 'c') +sql insert into t1 values('2017-12-25 21:25:41', 1) +sql insert into t1 values('2017-12-25 21:26:41', 1) +sql insert into t1 values('2017-12-25 21:27:41', 1) +sql insert into t1 values('2017-12-25 21:28:41', 1) +sql insert into t1 values('2017-12-25 21:29:41', 1) +sql insert into t2 values('2017-12-25 21:25:41', 2) +sql insert into t2 values('2017-12-25 21:26:41', 2) +sql insert into t2 values('2017-12-25 21:27:41', 2) +sql insert into t2 values('2017-12-25 21:28:41', 2) +sql insert into t3 values('2017-12-25 21:25:41', 3) +sql insert into t3 values('2017-12-25 21:26:41', 3) +sql insert into t3 values('2017-12-25 21:27:41', 3) + +print =============== step2 - login + +system_content curl 192.168.0.1:6020/grafana/ +print 1-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/grafana/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/grafana/login/xx/xx/ +print 3-> $system_content +if $system_content != @{"status":"error","code":35,"desc":"invalid user name"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/grafana/root/1/123/1/1/3 +print 4-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 192.168.0.1:6020/grafana/login/1/root/1/ +print 5-> $system_content +if $system_content != @{"status":"error","code":35,"desc":"invalid user name"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 192.168.0.1:6020/grafana/root/1/login +print 6-> $system_content +if $system_content != @{"status":"error","code":1010,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 192.168.0.1:6020/grafana/root/1/login +print 7-> $system_content +if $system_content != @{"status":"error","code":1010,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +sleep 3000 +system_content curl 192.168.0.1:6020/grafana/login/root/taosdata +print 8-> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +print =============== step3 - heartbeat + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/grafana/d1/table_gc +print 9-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +print =============== step4 - search + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/grafana/heartbeat +print 10-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/grafana/d1/table_invalid/search +print 11-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' 127.0.0.1:6020/grafana/d1/m1/search +print 12-> $system_content +if $system_content != @{"message":"Grafana server receive a quest from you!"}@ then + return -1 +endi + +print =============== step5 - query + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"taosd","sql":"select first(v1) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"},{"refId":"B","alias":"system","sql":"select first(v2) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"}]' 127.0.0.1:6020/grafana/query +print 13-> $system_content +if $system_content != @[{"refId":"A","target":"taosd","datapoints":[[2,1514208480000]]},{"refId":"B","target":"system","datapoints":[[5.10000,1514208480000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select first(v1) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"},{"refId":"B","alias":"","sql":"select first(v2) from d1.m1 where ts > 1514208523020 and ts < 1514208523030 interval(1m)"}]' 127.0.0.1:6020/grafana/query +print 14-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,1514208480000]]},{"refId":"B","target":"B","datapoints":[[5.10000,1514208480000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2) from d1.m1"}]' 127.0.0.1:6020/grafana/query +print 15-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[3,"-"]]},{"refId":"B","target":"B","datapoints":[[3,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2) from d1.m1"}]' 127.0.0.1:6020/grafana/query +print 15-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[3,"-"]]},{"refId":"B","target":"B","datapoints":[[3,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query +print 16-> $system_content +if $system_content != @[{"refId":"A","target":"1","datapoints":[[5,"-"]]},{"refId":"A","target":"2","datapoints":[[4,"-"]]},{"refId":"A","target":"3","datapoints":[[3,"-"]]},{"refId":"B","target":"a","datapoints":[[5,"-"]]},{"refId":"B","target":"b","datapoints":[[8,"-"]]},{"refId":"B","target":"c","datapoints":[[9,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt group by a"},{"refId":"B","alias":"sum-","sql":"select sum(i) from d1.mt group by b"}]' 127.0.0.1:6020/grafana/query +print 17-> $system_content +if $system_content != @[{"refId":"A","target":"count1","datapoints":[[5,"-"]]},{"refId":"A","target":"count2","datapoints":[[4,"-"]]},{"refId":"A","target":"count3","datapoints":[[3,"-"]]},{"refId":"B","target":"sum-a","datapoints":[[5,"-"]]},{"refId":"B","target":"sum-b","datapoints":[[8,"-"]]},{"refId":"B","target":"sum-c","datapoints":[[9,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"count","sql":"select count(i) from d1.mt interval(1m) group by a "}]' 127.0.0.1:6020/grafana/query +print 18-> $system_content +if $system_content != @[{"refId":"A","target":"count1","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000],[1,1514208540000]]},{"refId":"A","target":"count2","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000]]},{"refId":"A","target":"count3","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"refId":"A","alias":"","sql":"select sum(v2), count(v1) from d1.m1"},{"refId":"B","alias":"","sql":"select count(v2), sum(v2) from d1.m1"}]' 127.0.0.1:6020/grafana/query +print 19-> $system_content +if $system_content != @[{"refId":"A","target":"3","datapoints":[[15.299999714,"-"]]},{"refId":"B","target":"15.299999714","datapoints":[[3,"-"]]}]@ then + return -1 +endi diff --git a/tests/script/general/http/grafana_bug.sim b/tests/script/general/http/grafana_bug.sim new file mode 100644 index 0000000000..6f0e687fda --- /dev/null +++ b/tests/script/general/http/grafana_bug.sim @@ -0,0 +1,239 @@ +system sh/stop_dnodes.sh + +sleep 2000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============================ dnode1 start + +print =============== step0 - prepare data + +sql create database db +sql use db + +sql create table tb (ts timestamp, val int, val1 int, val2 int) +sql create table tb2 (ts timestamp, val int, val1 int, val2 int) +sql create table t2 (ts timestamp, val int) + +sql insert into tb values('2020-01-01 00:00:00.000', 1, 11, 21) +sql insert into tb values('2020-01-02 00:00:00.000', 1, 12, 22) +sql insert into tb values('2020-01-03 00:00:00.000', 2, 13, 23) +sql insert into tb values('2020-01-04 00:00:00.000', 2, 14, 24) + +sql insert into tb2 values('2020-01-01 00:00:00.000', 21, 211, 221) +sql insert into tb2 values('2020-01-02 00:00:00.000', 21, 212, 222) +sql insert into tb2 values('2020-01-03 00:00:00.000', 22, 213, 223) +sql insert into tb2 values('2020-01-04 00:00:00.000', 22, 214, 224) + +print =============== step1 - one query, 1 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then + return -1 +endi + +print =============== step2 - one query, 2 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step2-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step3 - one query, 3 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step3.1-> $system_content +if $system_content != @[{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb "} ]' 127.0.0.1:6020/grafana/query +print step3.2-> $system_content +if $system_content != @[{"refId":"A","target":"11","datapoints":[[1,1577808000000]]},{"refId":"A","target":"12","datapoints":[[1,1577894400000]]},{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val1,val from db.tb "} ]' 127.0.0.1:6020/grafana/query +print step3.3-> $system_content +if $system_content != @[{"refId":"A","target":"1","datapoints":[[11,1577808000000],[12,1577894400000]]},{"refId":"A","target":"2","datapoints":[[13,1577980800000],[14,1578067200000]]}]@ then + return -1 +endi + +print =============== step4 - one query, 4 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val2,val1,val from db.tb "} ]' 127.0.0.1:6020/grafana/query +print step4.1-> $system_content +if $system_content != @[{"refId":"A","target":"1","datapoints":[[21,1577808000000],[22,1577894400000]]},{"refId":"A","target":"2","datapoints":[[23,1577980800000],[24,1578067200000]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1,val2 from db.tb "} ]' 127.0.0.1:6020/grafana/query +print step4.2-> $system_content +if $system_content != @[{"refId":"A","target":"21","datapoints":[[1,1577808000000]]},{"refId":"A","target":"22","datapoints":[[1,1577894400000]]},{"refId":"A","target":"23","datapoints":[[2,1577980800000]]},{"refId":"A","target":"24","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step5 - one query, 1 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"A","datapoints":[[2,"-"],[2,"-"]]}]@ then + return -1 +endi + +print =============== step6 - one query, 2 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"23","datapoints":[[13,"-"]]},{"refId":"A","target":"24","datapoints":[[14,"-"]]}]@ then + return -1 +endi + +print =============== step7 - one query, 3 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"2","datapoints":[[13,"-"],[14,"-"]]}]@ then + return -1 +endi + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb"} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"A","target":"1","datapoints":[[11,"-"],[12,"-"]]},{"refId":"A","target":"2","datapoints":[[13,"-"],[14,"-"]]}]@ then + return -1 +endi + +print =============== step8 - one query, no return +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb where ts >= 1677980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step9 - one query, insert sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"insert into db.t2 values(now, 1) "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step10 - one query, error sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select * from db.tt "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[]@ then + return -1 +endi + +print =============== step11 - two query, 1 column, with timestamp, 1 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"A","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then + return -1 +endi + +print =============== step12 - two query, 1 column, with timestamp, 2 column, with timestamp + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step13 - two query, 1 column, with timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step14 - two query, 2 column, with timestamp, 2 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[223,1577980800000],[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step15 - two query, 2 column, with timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB213","datapoints":[[223,1577980800000]]},{"refId":"B","target":"BB214","datapoints":[[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step16 - two query, 3 column, with timestamp, 4 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val, val1, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB213","datapoints":[[22,1577980800000]]},{"refId":"B","target":"BB214","datapoints":[[22,1578067200000]]},{"refId":"A","target":"AA13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"AA14","datapoints":[[2,1578067200000]]}]@ then + return -1 +endi + +print =============== step17 - two query, 2 column, with timestamp, no return +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1677980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step18 - two query, 2 column, with timestamp, invalid sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb222 where ts >= 1677980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step19 - two query, 2 column, with timestamp, insert sql +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"insert into db.t2 values(now, 1)"} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,1577980800000],[22,1578067200000]]}]@ then + return -1 +endi + +print =============== step20 - two query, 1 column, no timestamp, 1 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then + return -1 +endi + +print =============== step21 - two query, 1 column, no timestamp, 2 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[[223,1577980800000],[224,1578067200000]]}]@ then + return -1 +endi + +print =============== step22 - two query, 1 column, no timestamp, 3 column, with timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val1, val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA223","datapoints":[[213,1577980800000]]},{"refId":"A","target":"AA224","datapoints":[[214,1578067200000]]}]@ then + return -1 +endi + +print =============== step23 - two query, 2 column, no timestamp, 1 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA","datapoints":[[213,"-"],[214,"-"]]}]@ then + return -1 +endi + +print =============== step24 - two query, 2 column, no timestamp, 2 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA213","datapoints":[[22,"-"]]},{"refId":"A","target":"AA214","datapoints":[[22,"-"]]}]@ then + return -1 +endi + +print =============== step25 - two query, 2 column, no timestamp, 3 column, no timestamp +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1,val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query +print step1-> $system_content +if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA223","datapoints":[[22,"-"]]},{"refId":"A","target":"AA224","datapoints":[[22,"-"]]}]@ then + return -1 +endi + diff --git a/tests/script/general/http/http.json b/tests/script/general/http/http.json new file mode 100644 index 0000000000..087f4eab5b --- /dev/null +++ b/tests/script/general/http/http.json @@ -0,0 +1,23 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 1, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbReplica": 1, + "dbKeep": 3650, + "dbDays": 7, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 100, + "dataBegin": 1485878400000, + "dataInterval": 1000, + "dataBatch": 1, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/httpTestNew.go b/tests/script/general/http/httpTestNew.go new file mode 100644 index 0000000000..7947f0a20a --- /dev/null +++ b/tests/script/general/http/httpTestNew.go @@ -0,0 +1,232 @@ +package main + +import ( + "bytes" + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" +) + +var ( + token string + url string + config Config + request int64 + begin time.Time + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + TableNum int `json:"tableNum"` + DbName string `json:"dbName"` + MetricsName string `json:"metricsName"` + DataNum int `json:"dataNum"` + BatchNum int `json:"batchNum"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos.json parse error") + panic(err) + } + + request = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("TableNum:", config.TableNum) + fmt.Println("dbName:", config.DbName) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("batchNum:", config.BatchNum) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for reTryTimes := 0; reTryTimes < 10; reTryTimes++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + + atomic.AddInt64(&request, 1) + + if (request*int64(config.BatchNum))%100000 == 0 && request != 0 { + spend := time.Since(begin).Seconds() + if spend >= 1 && spend < 10000000 { + total := (request - errorNum - 2 - int64(config.TableNum)) * int64(config.BatchNum) + fmt.Printf("request:%d, error:%d, insert:%d, spend:%.2f seconds, dps:%.1f \n", request, errorNum, total, spend, float64(total)/float64(spend)) + } + } + + return + } + + //fmt.Println("exec failed, sql:", sql) + errorNum++ +} + +func createDb() { + fmt.Println("================create database =====================") + + client := &http.Client{} + sql := fmt.Sprintf("create database %s", config.DbName) + exec(client, sql) +} + +func createTb() { + fmt.Println("================create table ========================") + + client := &http.Client{} + sql := fmt.Sprintf("create table %s.%s(ts timestamp, f1 int, f2 int) tags (tb int)", config.DbName, config.MetricsName) + exec(client, sql) + + for i := 0; i < config.TableNum; i++ { + sql := fmt.Sprintf("create table %s.t%d using %s.%s tags(%d)", config.DbName, i, config.DbName, config.MetricsName, i) + exec(client, sql) + } +} + +func insertData(wg *sync.WaitGroup, tableIndex int) { + defer wg.Done() + + client := &http.Client{} + beginTime := int64(1519833600000) + + for i := 0; i < config.DataNum; i += config.BatchNum { + var sql bytes.Buffer + sql.WriteString(fmt.Sprintf("insert into %s.t%d values", config.DbName, tableIndex)) + + for j := 0; j < config.BatchNum; j++ { + sql.WriteString(fmt.Sprintf("(%d,%d,%d)", beginTime+int64(i)+int64(j), rand.Intn(1000), rand.Intn(1000))) + } + exec(client, sql.String()) + } +} + +func main() { + filename := flag.String("config", "http.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + createDb() + createTb() + + begin = time.Now() + + var wg sync.WaitGroup + + fmt.Println("================insert data ========================") + for i := 0; i < config.TableNum; i++ { + wg.Add(1) + go insertData(&wg, i) + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + + spend := time.Since(begin).Seconds() + + total := (request - errorNum - 2 - int64(config.TableNum)) * int64(config.BatchNum) + fmt.Printf("request:%d, error:%d, insert:%d, spend:%.2f seconds, dps:%.1f \n", request, errorNum, total, spend, float64(total)/float64(spend)) +} diff --git a/tests/script/general/http/httpTest_cloud.go b/tests/script/general/http/httpTest_cloud.go new file mode 100644 index 0000000000..feb3f1450b --- /dev/null +++ b/tests/script/general/http/httpTest_cloud.go @@ -0,0 +1,372 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "tiger", "tiger")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func createDb() { + if !config.TableCreate { + return + } + + client := &http.Client{} + + fmt.Println("\n================create database =====================") + sql := fmt.Sprintf("create database %s keep %d", config.DbName, config.DbKeep) + exec(client, sql) +} + +func createTb() { + if !config.TableCreate { + return + } + client := &http.Client{} + + fmt.Println("\n================create table ========================") + sql := fmt.Sprintf("create table %s.%s(%s) tags (orgno int)", config.DbName, config.MetricsName, config.TableDesc) + exec(client, sql) + tbNum := config.TablePerConn*config.ConnNum + config.TableStart + for i := config.TableStart; i < tbNum; i++ { + sql := fmt.Sprintf("create table %s.%s%d using %s.%s tags(%d)", config.DbName, config.TablePrefix, i, config.DbName, config.MetricsName, i%config.TagNum+1) + exec(client, sql) + } + +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + for j := 0; j < config.DataNum; j++ { + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql += fmt.Sprintf("(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + for i := 0; i < config.DataNum; i++ { + exec(client, config.TableDesc) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + if config.InsertModel == "selectData" { + fmt.Println("\n================select data ========================") + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + } else { + createDb() + createTb() + + if config.DataInsert { + fmt.Println("\n================insert data ========================") + } + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/httpTest_private.go b/tests/script/general/http/httpTest_private.go new file mode 100644 index 0000000000..907b6c1d62 --- /dev/null +++ b/tests/script/general/http/httpTest_private.go @@ -0,0 +1,372 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "math/rand" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 +) + +type Config struct { + HostIp string `json:"hostIp"` + ConnNum int `json:"connNum"` + InsertModel string `json:"insertModel"` + WaitTime int `json:"waitTime"` + TableDesc string `json:"tableDesc"` + TablePrefix string `json:"tablePrefix"` + TablePerConn int `json:"tablePerConn"` + TableCreate bool `json:"tableCreate"` + TableStart int `json:"tableStart"` + DbName string `json:"dbName"` + DbReplica int `json:"dbReplica"` + DbKeep int `json:"dbKeep"` + DbDays int `json:"dbDays"` + MetricsName string `json:"metricsName"` + TagNum int `json:"tagNum"` + DataNum int `json:"dataNum"` + DataBegin int64 `json:"dataBegin"` + DataInterval int `json:"dataInterval"` + DataBatch int `json:"dataBatch"` + DataInsert bool `json:"dataInsert"` + DataRandom bool `json:"dataRandom"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readFile(filename string) { + file, err := os.Open(filename) + if err != nil { + println("taos_cloud.json not found") + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("taos_cloud.json parse error") + panic(err) + } + + if config.TagNum <= 0 { + config.TagNum = 1 + } + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("connNum:", config.ConnNum) + fmt.Println("insertModel:", config.InsertModel) + fmt.Println("waitTime:", config.WaitTime) + fmt.Println("tableDesc:", config.TableDesc) + fmt.Println("tablePrefix:", config.TablePrefix) + fmt.Println("tablePerConn:", config.TablePerConn) + fmt.Println("tableCreate:", config.TableCreate) + fmt.Println("tableStart:", config.TableStart) + fmt.Println("dbName:", config.DbName) + fmt.Println("dbReplica:", config.DbReplica) + fmt.Println("dbKeep:", config.DbKeep) + fmt.Println("dbDays:", config.DbDays) + fmt.Println("metricsName:", config.MetricsName) + fmt.Println("tagNum:", config.TagNum) + fmt.Println("dataNum:", config.DataNum) + fmt.Println("dataBegin:", config.DataBegin) + fmt.Println("dataInterval:", config.DataInterval) + fmt.Println("dataBatch:", config.DataBatch) + fmt.Println("dataInsert:", config.DataInsert) + fmt.Println("dataRandom:", config.DataRandom) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/rest/sql", config.HostIp, 6020) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 1; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + resp.Body.Close() + continue + } + + if jsonResult.Status != "succ" { + resp.Body.Close() + continue + } + atomic.AddInt64(&request, 1) + if (request < 103) { + return + } + + atomic.AddInt64(&period, spend) + if request%5000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + errorNum++ +} + +func createDb() { + if !config.TableCreate { + return + } + + client := &http.Client{} + + fmt.Println("\n================create database =====================") + sql := fmt.Sprintf("create database %s keep %d", config.DbName, config.DbKeep) + exec(client, sql) +} + +func createTb() { + if !config.TableCreate { + return + } + client := &http.Client{} + + fmt.Println("\n================create table ========================") + sql := fmt.Sprintf("create table %s.%s(%s) tags (orgno int)", config.DbName, config.MetricsName, config.TableDesc) + exec(client, sql) + tbNum := config.TablePerConn*config.ConnNum + config.TableStart + for i := config.TableStart; i < tbNum; i++ { + sql := fmt.Sprintf("create table %s.%s%d using %s.%s tags(%d)", config.DbName, config.TablePrefix, i, config.DbName, config.MetricsName, i%config.TagNum+1) + exec(client, sql) + } + +} + +func insertTable(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql += fmt.Sprintf("(%d, %d)", tmVal, dataVal) + } + + + exec(client, sql) + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + j += (config.DataBatch - 1) + } +} + +func insertLoop(conn int) { + client := &http.Client{} + + tbStart := conn*config.TablePerConn + config.TableStart + tmStart := config.DataBegin + + for j := 0; j < config.DataNum; j++ { + + for i := 0; i < config.TablePerConn; i++ { + tbIndex := i + tbStart + + tmVal := int64(j)*int64(config.DataInterval) + tmStart + + dataVal := j + if config.DataRandom { + dataVal = rand.Intn(1000) + } + + sql := fmt.Sprintf("insert into %s.%s%d values(%d, %d)", config.DbName, config.TablePrefix, tbIndex, tmVal, dataVal) + for k := 1; k < config.DataBatch; k++ { + tmVal := int64(j)*int64(config.DataInterval) + int64(k) + tmStart + + dataVal := j + k + if config.DataRandom { + dataVal = rand.Intn(1000) + } + sql += fmt.Sprintf("values(%d, %d)", tmVal, dataVal) + } + + j += (config.DataBatch - 1) + + exec(client, sql) + + if config.WaitTime != 0 { + time.Sleep(time.Millisecond * time.Duration(config.WaitTime)) + } + } + + } +} + +func insertTb(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + if !config.DataInsert { + return + } + + if config.InsertModel == "insertTable" { + insertTable(conn) + } else { + insertLoop(conn) + } +} + +func selectData(wg *sync.WaitGroup, conn int) { + defer wg.Done() + + client := &http.Client{} + + for i := 0; i < config.DataNum; i++ { + exec(client, config.TableDesc) + } +} + +func main() { + filename := flag.String("config", "taos_cloud.json", "config file name") + + flag.Parse() + + readFile(*filename) + + fmt.Println("\n================http test start======================") + + var wg sync.WaitGroup + + if config.InsertModel == "selectData" { + fmt.Println("\n================select data ========================") + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go selectData(&wg, i) + } + } else { + createDb() + createTb() + + if config.DataInsert { + fmt.Println("\n================insert data ========================") + } + + for i := 0; i < config.ConnNum; i++ { + wg.Add(1) + go insertTb(&wg, i) + } + } + + wg.Wait() + + fmt.Println("\n================http test stop ======================") + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.ConnNum) + dps := qps * float64(config.DataBatch) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/opentsdb.sim b/tests/script/general/http/opentsdb.sim new file mode 100644 index 0000000000..985f1827db --- /dev/null +++ b/tests/script/general/http/opentsdb.sim @@ -0,0 +1,238 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - parse +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/ +print $system_content +if $system_content != @{"status":"error","code":1057,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db123456789012345678901234567890db +print $system_content +if $system_content != @{"status":"error","code":1058,"desc":"database name too long"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/ +print $system_content +if $system_content != @{"status":"error","code":1057,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put2 +print $system_content +if $system_content != @{"status":"error","code":1009,"desc":"http url parse error"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1060,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1059,"desc":"invalid opentsdb json fromat"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{}' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1060,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content + +if $system_content != @{"status":"error","code":1062,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": 1,"timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1063,"desc":"metric name type should be string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1064,"desc":"metric name length is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "ab1234567890123456789012345678ab1234567890123456789012345678","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1065,"desc":"metric name length can not more than 22"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1066,"desc":"timestamp not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": "2","value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1067,"desc":"timestamp type should be integer"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": -1,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1068,"desc":"timestamp value smaller than 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1078,"desc":"value not find"}@ then + return -1 +endi + +####### + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1069,"desc":"tags not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1070,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": 0}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1070,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","group1": "1","group1": "1","group1": "1","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1071,"desc":"tags size too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"": "web01"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1073,"desc":"tag name is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host01123456789001123456789001123456789001123456789001123456789001123456789": "01"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1074,"desc":"tag name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web011234567890011234567890011234567890011234567890011234567890011234567890011234567890011234567890"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1077,"desc":"tag value can not more than 64"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": ""}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"status":"error","code":1076,"desc":"tag value is null"}@ then + return -1 +endi + +sleep 3000 + +print =============== step2 - insert single data +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846400000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":1,"status":"succ"}}],"failed":0,"success":1,"affected_rows":1}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +print $system_content +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846400000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":0,"status":"succ"}}],"failed":0,"success":1,"affected_rows":0}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_web01' 127.0.0.1:6020/rest/sql/ +print $system_content +if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",18.000000000]],"rows":1}@ then + return -1 +endi + +print =============== step3 - multi-query data +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846401000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846402000,"value": 18,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put + +print $system_content + +if $system_content != @{"errors":[{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web01","timestamp":1346846401000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"affected_rows":1,"status":"succ"}},{"datapoint":{"metric":"sys_cpu","stable":"sys_cpu_d_bbb","table":"sys_cpu_d_bbb_lga_1_web02","timestamp":1346846402000,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web02"},"affected_rows":1,"status":"succ"}}],"failed":0,"success":2,"affected_rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_cpu_d_bbb_lga_1_web01' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",18.000000000],["2012-09-05 20:00:01.000",18.000000000]],"rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"data":[[3]],"rows":1}@ then + return -1 +endi + +print =============== step4 - summary-put data +system_content curl -u root:taosdata -d '[{"metric": "sys_mem","timestamp": 1346846400000,"value": 8,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_mem","timestamp": 1346846401000,"value": 9,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put?details=false + +print $system_content + +if $system_content != @{"failed":0,"success":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.sys_mem_d_bbb_lga_1_web01' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","value"],"data":[["2012-09-05 20:00:00.000",8.000000000],["2012-09-05 20:00:01.000",9.000000000]],"rows":2}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_mem_d_bbb' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"data":[[2]],"rows":1}@ then + return -1 +endi + +print =============== step5 - prepare data + +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846402000,"value": 19,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846402,"value": 19,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846403000,"value": 20,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846403,"value": 20,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846404000,"value": 21,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846404,"value": 21,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846405000,"value": 22,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846405,"value": 22,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put +system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846406000,"value": 23,"tags": {"host": "web01","group1": "1","dc": "lga"}},{"metric": "sys_cpu","timestamp": 1346846406,"value": 23,"tags": {"host": "web02","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put + +system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' 127.0.0.1:6020/rest/sql/ +print $system_content +if $system_content != @{"status":"succ","head":["count(*)"],"data":[[8]],"rows":1}@ then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/http/prepare.sim b/tests/script/general/http/prepare.sim new file mode 100644 index 0000000000..dcbaa7ef81 --- /dev/null +++ b/tests/script/general/http/prepare.sim @@ -0,0 +1,54 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table t1 (ts timestamp, i int, b binary(100)) + +sql insert into t1 values('2017-12-25 21:28:41.022', 1, 11) +sql insert into t1 values('2017-12-25 21:28:42.022', 2, '22') +sql insert into t1 values('2017-12-25 21:28:43.022', 3, "33") +sql insert into t1 values('2017-12-25 21:28:44.022', 4, '44"') +sql insert into t1 values('2017-12-25 21:28:45.022', 5, "55'") +sql insert into t1 values('2017-12-25 21:28:46.022', 6, "66'6'") +sql insert into t1 values('2017-12-25 21:28:47.022', 7, '77"7"') +sql insert into t1 values('2017-12-25 21:28:48.022', 8, '88""88') +sql insert into t1 values('2017-12-25 21:28:49.022', 9, '99\99') +sql insert into t1 values('2017-12-25 21:28:51.022', 11, '11\\11') +sql insert into t1 values('2017-12-25 21:28:52.022', 12, '22\\11') +sql insert into t1 values('2017-12-25 21:28:53.022', 13, '33\\"33') +sql insert into t1 values('2017-12-25 21:28:54.022', 14, '44\\""44') + +sleep 4000 + +print =============== step2 - login + +system_content curl 127.0.0.1:6020/rest/login/root/taosdata +print curl 127.0.0.1:6020/rest/login/root/taosdata -----> $system_content + +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +return + +print =============== step3 - query data + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwia2V5IjoiYkVsOExjdkxVZDdhOHFkdE5abXRPTnJ5cDIwMW1hMDQiLCJzdWIiOiJyb290In0.k7CkgmpOJImIkLqZqzASlPmkdeEw7Wfk4XUrqGZX-LQ' -d 'select * from t1' 127.0.0.1:6020/rest/sql/d1 +print curl 127.0.0.1:6020/rest/sql/d1 -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i","b"],"data":[["2017-12-25 21:28:54.022",14,"44\\\\\"\"44"],["2017-12-25 21:28:53.022",13,"33\\\\\"33"],["2017-12-25 21:28:52.022",12,"22\\\\11"],["2017-12-25 21:28:51.022",11,"11\\\\11"],["2017-12-25 21:28:49.022",9,"99\\99"],["2017-12-25 21:28:48.022",8,"88\"\"88"],["2017-12-25 21:28:47.022",7,"77\"7\""],["2017-12-25 21:28:46.022",6,"66'6'"],["2017-12-25 21:28:45.022",5,"55'"],["2017-12-25 21:28:44.022",4,"44\""],["2017-12-25 21:28:43.022",3,"33"],["2017-12-25 21:28:42.022",2,"22"],["2017-12-25 21:28:41.022",1,"11"]],"rows":13}@ then + return -1 +endi diff --git a/tests/script/general/http/restful.sim b/tests/script/general/http/restful.sim new file mode 100644 index 0000000000..4c0adae41d --- /dev/null +++ b/tests/script/general/http/restful.sim @@ -0,0 +1,84 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table table_rest (ts timestamp, i int) + +sql insert into table_rest values('2017-12-25 21:28:41.022', 1) +sql insert into table_rest values('2017-12-25 21:28:42.022', 2) +sql insert into table_rest values('2017-12-25 21:28:43.022', 3) +sql insert into table_rest values('2017-12-25 21:28:44.022', 4) +sql insert into table_rest values('2017-12-25 21:28:45.022', 5) +sql insert into table_rest values('2017-12-25 21:28:46.022', 6) +sql insert into table_rest values('2017-12-25 21:28:47.022', 7) +sql insert into table_rest values('2017-12-25 21:28:48.022', 8) +sql insert into table_rest values('2017-12-25 21:28:49.022', 9) +sql insert into table_rest values('2017-12-25 21:28:50.022', 10) + +print =============== step2 - login + +system_content curl 127.0.0.1:6020/rest/login/root/taosdata +print curl 127.0.0.1:6020/rest/login/root/taosdata -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +print =============== step3 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +print =============== step4 - insert data +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.table_rest values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + return -1 +endi + +print =============== step6 - query no db data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show dnodes' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content + +print =============== step7 - change password +sql create user u1 PASS 'abcd@1234' +sql create user u2 PASS 'abcd_1234' + +system_content curl 127.0.0.1:6020/rest/login/u1/abcd@1234 +print curl 127.0.0.1:6020/rest/login/u1/abcd@1234 -----> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"jIlItaLFFIPa8qdtNZmtONryp201ma04SXX8PEJowKAB/46k1gwnPNryp201ma04"}@ then + return -1 +endi + +system_content curl 127.0.0.1:6020/rest/login/u2/abcd_1234 +print curl 127.0.0.1:6020/rest/login/u2/abcd_1234 -----> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"AZH3lNvWZiLa8qdtNZmtONryp201ma04QExCHYkbFFQB/46k1gwnPNryp201ma04"}@ then + return -1 +endi diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim new file mode 100644 index 0000000000..2be125021d --- /dev/null +++ b/tests/script/general/http/restful_full.sim @@ -0,0 +1,234 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - login + +system_content curl 192.168.0.1:6020/rest/ +print 1-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/rest/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/rest/login +print 3-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +#4 +system_content curl 192.168.0.1:6020/rest/login/root +print 4-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/rest/login/root/123 +print 5-> $system_content +if $system_content != @{"status":"error","code":10,"desc":"authentication failure"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/rest/login/root/123/1/1/3 +print 6-> $system_content +if $system_content != @{"status":"error","code":10,"desc":"authentication failure"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 192.168.0.1:6020/rest/login/root/1 +print 7-> $system_content +if $system_content != @{"status":"error","code":10,"desc":"authentication failure"}@ then + return -1 +endi + +#8 +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 192.168.0.1:6020/rest/login/root/1 +print 8-> $system_content +if $system_content != @{"status":"error","code":1010,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 192.168.0.1:6020/rest/login/root/1 +print 9-> $system_content +if $system_content != @{"status":"error","code":1010,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +sleep 3000 + +system_content curl 192.168.0.1:6020/rest/login/root/taosdata/ +print 10-> $system_content +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +print =============== step2 - no db + +#11 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 192.168.0.1:6020/rest/sql +print 11-> $system_content +if $system_content != @{"status":"succ","head":["name","created time","ntables","vgroups","replica","days","keep1,keep2,keep(D)","tables","rows","cache(b)","ablocks","tblocks","ctime(s)","clog","comp","time precision","status"],"data":[],"rows":0}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 192.168.0.1:6020/rest/sql +print 12-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 192.168.0.1:6020/rest/sql +print 13-> $system_content +if $system_content != @{"status":"error","code":33,"desc":"DB already there"}@ then + return -1 +endi + +#14 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '' 192.168.0.1:6020/rest/sql +print 14-> $system_content +if $system_content != @{"status":"error","code":1012,"desc":"no sql input"}@ then + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'use d1' 192.168.0.1:6020/rest/sql +#print 15-> $system_content +#if $system_content != @{"status":"error","code":1017,"desc":"no need to execute use db cmd"}@ then +#if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then +# return -1 +#endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' use d1' 192.168.0.1:6020/rest/sql +#print 16-> $system_content +#if $system_content != @{"status":"error","code":1017,"desc":"no need to execute use db cmd"}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' used1' 192.168.0.1:6020/rest/sql +print 17-> $system_content +if $system_content != @{"status":"error","code":28,"desc":"invalid SQL: invalid SQL: syntax error near 'used1'"}@ then + return -1 +endi + +#18 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 192.168.0.1:6020/rest/sql +print 18-> $system_content +if $system_content != @{"status":"error","code":38,"desc":"DB not selected"}@ then + return -1 +endi + +print =============== step3 - db + +#19 +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 192.168.0.1:6020/rest/sql/d4 +#print 19-> $system_content +#if $system_content != @{"status":"error","code":102,"desc":"invalid DB"}@ then +# return -1 +#endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 192.168.0.1:6020/rest/sql/d1 +#print 20-> $system_content +#if $system_content != @{"status":"succ","head":["name","created time","columns","metric"],"data":[],"rows":0}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1;' 192.168.0.1:6020/rest/sql +print 21-> $system_content +if $system_content != @{"status":"error","code":32,"desc":"invalid table"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 192.168.0.1:6020/rest/sql +print 22-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 192.168.0.1:6020/rest/sql +print 23-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"data":[],"rows":0}@ then + return -1 +endi + +#24 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:41.022', 1)" 192.168.0.1:6020/rest/sql +print 24-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 192.168.0.1:6020/rest/sql +print 25-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then + return -1 +endi + +#26 +print 25-> no print +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:42.022', 2)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:43.022', 3)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:44.022', 4)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:45.022', 5)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:46.022', 6)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:47.022', 7)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:48.022', 8)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:49.022', 9)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:50.022', 10)" 192.168.0.1:6020/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:51.022', 11)" 192.168.0.1:6020/rest/sql + +#27 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 192.168.0.1:6020/rest/sql +print 27-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d2' 192.168.0.1:6020/rest/sql +print 28-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 192.168.0.1:6020/rest/sql +print 29-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +#30 +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d2.t1 values('2017-12-25 21:28:41.022', 1)" 192.168.0.1:6020/rest/sql +print 30-> $system_content +if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d2.t1 ' 192.168.0.1:6020/rest/sql +print 31-> $system_content +if $system_content != @{"status":"succ","head":["ts","speed"],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then + return -1 +endi + diff --git a/tests/script/general/http/restful_insert.sim b/tests/script/general/http/restful_insert.sim new file mode 100644 index 0000000000..e131e3e53e --- /dev/null +++ b/tests/script/general/http/restful_insert.sim @@ -0,0 +1,53 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data +sql create database d1 +sql use d1 + +sql create table d1.table_rest0 (ts timestamp, i int) +sql create table d1.table_rest1 (ts timestamp, i int) +sql create table d1.table_rest2 (ts timestamp, i int) +sql create table d1.table_rest3 (ts timestamp, i int) +sql create table d1.table_rest4 (ts timestamp, i int) +sql create table d1.table_rest5 (ts timestamp, i int) +sql create table d1.table_rest6 (ts timestamp, i int) +sql create table d1.table_rest7 (ts timestamp, i int) +sql create table d1.table_rest8 (ts timestamp, i int) +sql create table d1.table_rest9 (ts timestamp, i int) + +print =============== step2 - login + +system_content curl 127.0.0.1:6020/rest/login/root/taosdata +print curl 127.0.0.1:6020/rest/login/root/taosdata -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +print =============== step3 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest1' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content diff --git a/tests/script/general/http/restful_limit.sim b/tests/script/general/http/restful_limit.sim new file mode 100644 index 0000000000..75d83b61b3 --- /dev/null +++ b/tests/script/general/http/restful_limit.sim @@ -0,0 +1,45 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - prepare data + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint, t1 bigint, t2 bigint, t3 bigint, t4 bigint, t5 bigint, t6 bigint, t7 bigint, t8 bigint, t9 bigint, t0 nchar(20)) TAGS(tgcol bigint) + +$i = 0 +while $i < 2 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < 2000 + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '你好' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from db0.st0 limit 100' 127.0.0.1:6020/rest/sql +print curl 127.0.0.1:6020/rest/sql -----> $system_content + +#system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d "select * from db0.st0 where tbname in ('tb0', 'tb1') limit 1000" 127.0.0.1:6020/rest/sql +#print curl 127.0.0.1:6020/rest/sql -----> $system_content diff --git a/tests/script/general/http/taos.json b/tests/script/general/http/taos.json new file mode 100644 index 0000000000..abc25f19a2 --- /dev/null +++ b/tests/script/general/http/taos.json @@ -0,0 +1,23 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 1, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp, i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbReplica": 1, + "dbKeep": 3650, + "dbDays": 7, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 1000, + "dataBegin": 1485878400000, + "dataInterval": 1000, + "dataBatch": 1000, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/taos_cloud.json b/tests/script/general/http/taos_cloud.json new file mode 100644 index 0000000000..c54186b65c --- /dev/null +++ b/tests/script/general/http/taos_cloud.json @@ -0,0 +1,21 @@ +{ + "hostIp": "192.168.100.128", + "connNum": 10, + "insertModel": "insertTable", + "waitTime": 0, + "tableDesc": "ts timestamp, i int", + "tablePrefix": "t", + "tablePerConn": 1, + "tableCreate": true, + "tableStart": 1, + "dbName": "db", + "dbKeep": 3650, + "metricsName": "mt", + "tagNum": 10, + "dataNum": 1000, + "dataBegin": 1517414400000, + "dataInterval": 1000, + "dataBatch": 1000, + "dataInsert": true, + "dataRandom": false +} diff --git a/tests/script/general/http/telegraf.json b/tests/script/general/http/telegraf.json new file mode 100644 index 0000000000..baf7c5e711 --- /dev/null +++ b/tests/script/general/http/telegraf.json @@ -0,0 +1,7 @@ +{ + "hostIp": "192.168.0.1", + "machineNum": 100, + "loopNum": 100, + "dbName": "db", + "dataBegin": 1485878400000 +} diff --git a/tests/script/general/http/telegraf.req b/tests/script/general/http/telegraf.req new file mode 100644 index 0000000000..1a3b732999 --- /dev/null +++ b/tests/script/general/http/telegraf.req @@ -0,0 +1,621 @@ +{ + "metrics": [{ + "fields": { + "result_code": 2, + "result_type": "connection_failed" + }, + "name": "net_response", + "tags": { + "host": "panshi-gsl", + "port": "80", + "protocol": "tcp", + "result": "connection_failed", + "server": "localhost" + }, + "timestamp": 1536750390000 + },{ + "fields": { + "load1": 0.27, + "load15": 0.09, + "load5": 0.22, + "n_cpus": 4, + "n_users": 4 + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + },{ + "fields": { + "uptime": 122 + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "uptime_format": " 0:02" + }, + "name": "system", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "bytes_recv": 19964, + "bytes_sent": 11077, + "drop_in": 0, + "drop_out": 0, + "err_in": 0, + "err_out": 0, + "packets_recv": 237, + "packets_sent": 124 + }, + "name": "net", + "tags": { + "host": "panshi-gsl", + "interface": "eth0" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.39879759519036, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.300601202404812, + "usage_user": 0.30060120240480753 + }, + "name": "cpu", + "tags": { + "cpu": "cpu0", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.79959919839683, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.2004008016032065, + "usage_user": 0 + }, + "name": "cpu", + "tags": { + "cpu": "cpu1", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.7999999999999, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0, + "usage_steal": 0, + "usage_system": 0.10000000000000217, + "usage_user": 0.09999999999999995 + }, + "name": "cpu", + "tags": { + "cpu": "cpu2", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.7999999999999, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0.09999999999999988, + "usage_steal": 0, + "usage_system": 0.09999999999999995, + "usage_user": 0 + }, + "name": "cpu", + "tags": { + "cpu": "cpu3", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "usage_guest": 0, + "usage_guest_nice": 0, + "usage_idle": 99.74956173303289, + "usage_iowait": 0, + "usage_irq": 0, + "usage_nice": 0, + "usage_softirq": 0.025043826696719312, + "usage_steal": 0, + "usage_system": 0.12521913348359823, + "usage_user": 0.10017530678687725 + }, + "name": "cpu", + "tags": { + "cpu": "cpu-total", + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "icmp_inaddrmaskreps": 0, + "icmp_inaddrmasks": 0, + "icmp_indestunreachs": 1, + "icmp_inechoreps": 0, + "icmp_inechos": 0, + "icmp_inerrors": 0, + "icmp_inmsgs": 1, + "icmp_inparmprobs": 0, + "icmp_inredirects": 0, + "icmp_insrcquenchs": 0, + "icmp_intimeexcds": 0, + "icmp_intimestampreps": 0, + "icmp_intimestamps": 0, + "icmp_outaddrmaskreps": 0, + "icmp_outaddrmasks": 0, + "icmp_outdestunreachs": 5, + "icmp_outechoreps": 0, + "icmp_outechos": 0, + "icmp_outerrors": 0, + "icmp_outmsgs": 5, + "icmp_outparmprobs": 0, + "icmp_outredirects": 0, + "icmp_outsrcquenchs": 0, + "icmp_outtimeexcds": 0, + "icmp_outtimestampreps": 0, + "icmp_outtimestamps": 0, + "icmpmsg_intype3": 1, + "icmpmsg_outtype3": 5, + "ip_defaultttl": 64, + "ip_forwarding": 2, + "ip_forwdatagrams": 0, + "ip_fragcreates": 0, + "ip_fragfails": 0, + "ip_fragoks": 0, + "ip_inaddrerrors": 0, + "ip_indelivers": 132, + "ip_indiscards": 0, + "ip_inhdrerrors": 0, + "ip_inreceives": 132, + "ip_inunknownprotos": 0, + "ip_outdiscards": 0, + "ip_outnoroutes": 40, + "ip_outrequests": 134, + "ip_reasmfails": 0, + "ip_reasmoks": 0, + "ip_reasmreqds": 0, + "ip_reasmtimeout": 0, + "tcp_activeopens": 11, + "tcp_attemptfails": 11, + "tcp_currestab": 0, + "tcp_estabresets": 0, + "tcp_inerrs": 0, + "tcp_insegs": 22, + "tcp_maxconn": -1, + "tcp_outrsts": 11, + "tcp_outsegs": 22, + "tcp_passiveopens": 0, + "tcp_retranssegs": 0, + "tcp_rtoalgorithm": 1, + "tcp_rtomax": 120000, + "tcp_rtomin": 200, + "udp_indatagrams": 101, + "udp_inerrors": 0, + "udp_noports": 5, + "udp_outdatagrams": 109, + "udp_rcvbuferrors": 0, + "udp_sndbuferrors": 0, + "udplite_indatagrams": 0, + "udplite_inerrors": 0, + "udplite_noports": 0, + "udplite_outdatagrams": 0, + "udplite_rcvbuferrors": 0, + "udplite_sndbuferrors": 0 + }, + "name": "net", + "tags": { + "host": "panshi-gsl", + "interface": "all" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 44, + "iops_in_progress": 0, + "read_bytes": 569344, + "read_time": 44, + "reads": 108, + "weighted_io_time": 44, + "write_bytes": 0, + "write_time": 0, + "writes": 0 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda5" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 4900, + "iops_in_progress": 0, + "read_bytes": 262294528, + "read_time": 13607, + "reads": 8122, + "weighted_io_time": 27970, + "write_bytes": 12054528, + "write_time": 14369, + "writes": 1073 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 4874, + "iops_in_progress": 0, + "read_bytes": 261522432, + "read_time": 13538, + "reads": 7963, + "weighted_io_time": 27901, + "write_bytes": 12054528, + "write_time": 14369, + "writes": 1073 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda1" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "io_time": 15, + "iops_in_progress": 0, + "read_bytes": 2048, + "read_time": 15, + "reads": 2, + "weighted_io_time": 15, + "write_bytes": 0, + "write_time": 0, + "writes": 0 + }, + "name": "diskio", + "tags": { + "host": "panshi-gsl", + "name": "sda2" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "free": 4106956800, + "inodes_free": 526746, + "inodes_total": 752192, + "inodes_used": 225446, + "total": 12112691200, + "used": 7390433280, + "used_percent": 64.27922535963918 + }, + "name": "disk", + "tags": { + "device": "rootfs", + "fstype": "rootfs", + "host": "panshi-gsl", + "mode": "rw", + "path": "/" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "free": 4106956800, + "inodes_free": 526746, + "inodes_total": 752192, + "inodes_used": 225446, + "total": 12112691200, + "used": 7390433280, + "used_percent": 64.27922535963918 + }, + "name": "disk", + "tags": { + "device": "disk/by-uuid/d4becabf-b49c-4c1c-a4ea-b2f593018766", + "fstype": "ext3", + "host": "panshi-gsl", + "mode": "rw", + "path": "/" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "boot_time": 1536750268, + "context_switches": 135890, + "entropy_avail": 514, + "interrupts": 112317, + "processes_forked": 3595 + }, + "name": "kernel", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "active": 211845120, + "available": 3829399552, + "available_percent": 92.37877479393148, + "buffered": 12083200, + "cached": 254320640, + "commit_limit": 2648322048, + "committed_as": 549027840, + "dirty": 49152, + "free": 3562995712, + "high_free": 0, + "high_total": 0, + "huge_page_size": 2097152, + "huge_pages_free": 0, + "huge_pages_total": 0, + "inactive": 214351872, + "low_free": 0, + "low_total": 0, + "mapped": 81797120, + "page_tables": 13062144, + "shared": 2682880, + "slab": 33386496, + "swap_cached": 0, + "swap_free": 575660032, + "swap_total": 575660032, + "total": 4145324032, + "used": 315924480, + "used_percent": 7.621225206068523, + "vmalloc_chunk": 35184198369280, + "vmalloc_total": 35184372087808, + "vmalloc_used": 168906752, + "wired": 0, + "write_back": 0, + "write_back_tmp": 0 + }, + "name": "mem", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "IpExtInBcastOctets": 1291, + "IpExtInBcastPkts": 6, + "IpExtInMcastOctets": 0, + "IpExtInMcastPkts": 0, + "IpExtInNoRoutes": 0, + "IpExtInOctets": 12160, + "IpExtInTruncatedPkts": 0, + "IpExtOutBcastOctets": 0, + "IpExtOutBcastPkts": 0, + "IpExtOutMcastOctets": 0, + "IpExtOutMcastPkts": 0, + "IpExtOutOctets": 9881, + "TcpExtArpFilter": 0, + "TcpExtDelayedACKLocked": 0, + "TcpExtDelayedACKLost": 0, + "TcpExtDelayedACKs": 0, + "TcpExtEmbryonicRsts": 0, + "TcpExtListenDrops": 0, + "TcpExtListenOverflows": 0, + "TcpExtLockDroppedIcmps": 0, + "TcpExtOfoPruned": 0, + "TcpExtOutOfWindowIcmps": 0, + "TcpExtPAWSActive": 0, + "TcpExtPAWSEstab": 0, + "TcpExtPAWSPassive": 0, + "TcpExtPruneCalled": 0, + "TcpExtRcvPruned": 0, + "TcpExtSyncookiesFailed": 0, + "TcpExtSyncookiesRecv": 0, + "TcpExtSyncookiesSent": 0, + "TcpExtTCPAbortFailed": 0, + "TcpExtTCPAbortOnClose": 0, + "TcpExtTCPAbortOnData": 0, + "TcpExtTCPAbortOnLinger": 0, + "TcpExtTCPAbortOnMemory": 0, + "TcpExtTCPAbortOnSyn": 0, + "TcpExtTCPAbortOnTimeout": 0, + "TcpExtTCPDSACKIgnoredNoUndo": 0, + "TcpExtTCPDSACKIgnoredOld": 0, + "TcpExtTCPDSACKOfoRecv": 0, + "TcpExtTCPDSACKOfoSent": 0, + "TcpExtTCPDSACKOldSent": 0, + "TcpExtTCPDSACKRecv": 0, + "TcpExtTCPDSACKUndo": 0, + "TcpExtTCPDirectCopyFromBacklog": 0, + "TcpExtTCPDirectCopyFromPrequeue": 0, + "TcpExtTCPFACKReorder": 0, + "TcpExtTCPFastRetrans": 0, + "TcpExtTCPForwardRetrans": 0, + "TcpExtTCPFullUndo": 0, + "TcpExtTCPHPAcks": 0, + "TcpExtTCPHPHits": 0, + "TcpExtTCPHPHitsToUser": 0, + "TcpExtTCPLoss": 0, + "TcpExtTCPLossFailures": 0, + "TcpExtTCPLossUndo": 0, + "TcpExtTCPLostRetransmit": 0, + "TcpExtTCPMD5NotFound": 0, + "TcpExtTCPMD5Unexpected": 0, + "TcpExtTCPMemoryPressures": 0, + "TcpExtTCPPartialUndo": 0, + "TcpExtTCPPrequeueDropped": 0, + "TcpExtTCPPrequeued": 0, + "TcpExtTCPPureAcks": 0, + "TcpExtTCPRcvCollapsed": 0, + "TcpExtTCPRenoFailures": 0, + "TcpExtTCPRenoRecovery": 0, + "TcpExtTCPRenoRecoveryFail": 0, + "TcpExtTCPRenoReorder": 0, + "TcpExtTCPSACKDiscard": 0, + "TcpExtTCPSACKReneging": 0, + "TcpExtTCPSACKReorder": 0, + "TcpExtTCPSackFailures": 0, + "TcpExtTCPSackMerged": 0, + "TcpExtTCPSackRecovery": 0, + "TcpExtTCPSackRecoveryFail": 0, + "TcpExtTCPSackShiftFallback": 0, + "TcpExtTCPSackShifted": 0, + "TcpExtTCPSchedulerFailed": 0, + "TcpExtTCPSlowStartRetrans": 0, + "TcpExtTCPSpuriousRTOs": 0, + "TcpExtTCPTSReorder": 0, + "TcpExtTCPTimeouts": 0, + "TcpExtTW": 0, + "TcpExtTWKilled": 0, + "TcpExtTWRecycled": 0 + }, + "name": "nstat", + "tags": { + "host": "panshi-gsl", + "name": "netstat" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "IcmpInAddrMaskReps": 0, + "IcmpInAddrMasks": 0, + "IcmpInDestUnreachs": 1, + "IcmpInEchoReps": 0, + "IcmpInEchos": 0, + "IcmpInErrors": 0, + "IcmpInMsgs": 1, + "IcmpInParmProbs": 0, + "IcmpInRedirects": 0, + "IcmpInSrcQuenchs": 0, + "IcmpInTimeExcds": 0, + "IcmpInTimestampReps": 0, + "IcmpInTimestamps": 0, + "IcmpMsgInType3": 1, + "IcmpMsgOutType3": 5, + "IcmpOutAddrMaskReps": 0, + "IcmpOutAddrMasks": 0, + "IcmpOutDestUnreachs": 5, + "IcmpOutEchoReps": 0, + "IcmpOutEchos": 0, + "IcmpOutErrors": 0, + "IcmpOutMsgs": 5, + "IcmpOutParmProbs": 0, + "IcmpOutRedirects": 0, + "IcmpOutSrcQuenchs": 0, + "IcmpOutTimeExcds": 0, + "IcmpOutTimestampReps": 0, + "IcmpOutTimestamps": 0, + "IpDefaultTTL": 64, + "IpForwDatagrams": 0, + "IpForwarding": 2, + "IpFragCreates": 0, + "IpFragFails": 0, + "IpFragOKs": 0, + "IpInAddrErrors": 0, + "IpInDelivers": 132, + "IpInDiscards": 0, + "IpInHdrErrors": 0, + "IpInReceives": 132, + "IpInUnknownProtos": 0, + "IpOutDiscards": 0, + "IpOutNoRoutes": 40, + "IpOutRequests": 134, + "IpReasmFails": 0, + "IpReasmOKs": 0, + "IpReasmReqds": 0, + "IpReasmTimeout": 0, + "TcpActiveOpens": 12, + "TcpAttemptFails": 12, + "TcpCurrEstab": 0, + "TcpEstabResets": 0, + "TcpInErrs": 0, + "TcpInSegs": 24, + "TcpMaxConn": -1, + "TcpOutRsts": 12, + "TcpOutSegs": 24, + "TcpPassiveOpens": 0, + "TcpRetransSegs": 0, + "TcpRtoAlgorithm": 1, + "TcpRtoMax": 120000, + "TcpRtoMin": 200, + "UdpInDatagrams": 101, + "UdpInErrors": 0, + "UdpLiteInDatagrams": 0, + "UdpLiteInErrors": 0, + "UdpLiteNoPorts": 0, + "UdpLiteOutDatagrams": 0, + "UdpLiteRcvbufErrors": 0, + "UdpLiteSndbufErrors": 0, + "UdpNoPorts": 5, + "UdpOutDatagrams": 109, + "UdpRcvbufErrors": 0, + "UdpSndbufErrors": 0 + }, + "name": "nstat", + "tags": { + "host": "panshi-gsl", + "name": "snmp" + }, + "timestamp": 1536750390000 + }, + { + "fields": { + "blocked": 0, + "dead": 0, + "idle": 0, + "paging": 0, + "running": 1, + "sleeping": 181, + "stopped": 0, + "total": 182, + "total_threads": 280, + "unknown": 0, + "zombies": 0 + }, + "name": "processes", + "tags": { + "host": "panshi-gsl" + }, + "timestamp": 1536750390000 + }] +} \ No newline at end of file diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim new file mode 100644 index 0000000000..1667034f0e --- /dev/null +++ b/tests/script/general/http/telegraf.sim @@ -0,0 +1,293 @@ +system sh/stop_dnodes.sh + +sleep 5000 + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 +system sh/cfg.sh -n dnode1 -c telegrafUseFieldNum -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +print =============== step1 - parse +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ +print $system_content + +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ +print $system_content + +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/d123456789012345678901234567890123456 +print $system_content + +if $system_content != @{"status":"error","code":1023,"desc":"database name too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[]' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1027,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1027,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '[{}]' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1027,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": []}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1025,"desc":"metrics size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": [{}]}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1027,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"metrics": 12}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1025,"desc":"metrics size is 0"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"metrics": [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +#print $system_content + +#if $system_content != @{"status":"error","code":1026,"desc":"metrics size can not more than 50"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1027,"desc":"metric name not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":111,"tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1028,"desc":"metric name type should be string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1029,"desc":"metric name length is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1030,"desc":"metric name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"}}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1031,"desc":"timestamp not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":""}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1032,"desc":"timestamp type should be integer"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":-1}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1033,"desc":"timestamp value smaller than 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1034,"desc":"tags not find"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1035,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":"","timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1035,"desc":"tags size is 0"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor","host":"windows","instance":"1","objectname":"Processor","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata +#print $system_content + +#if $system_content != @{"status":"error","code":1036,"desc":"tags size too long"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1035,"desc":"tags size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"":"windows"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1038,"desc":"tag name is null"}@ then + return -1 +endi + +#system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host111111111111222222222222222222222":""},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +#print $system_content + +#if $system_content != @{"status":"error","code":1039,"desc":"tag name length too long"}@ then +# return -1 +#endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":true},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1040,"desc":"tag value type should be number or string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":""},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1041,"desc":"tag value is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"1022":"111"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1042,"desc":"table is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"host111111111111222222222222222222222host111111111111222222222222222222222"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1043,"desc":"table name length too long"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1045,"desc":"fields size is 0"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1048,"desc":"field name is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":"","Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1051,"desc":"field value is null"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":true,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 +print $system_content + +if $system_content != @{"status":"error","code":1050,"desc":"field value type should be number or string"}@ then + return -1 +endi + +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1564641722000}' 127.0.0.1:6020/telegraf/db + +print $system_content + +if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_windows_1_Processor","timestamp":"1564641722000","affected_rows":1,"status":"succ"}]}@ then + return -1 +endi + +sleep 3000 + +print =============== step2 - insert single data +system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1564641722000}' 127.0.0.1:6020/telegraf/db/ + +print $system_content + +if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_windows_1_Processor","timestamp":"1564641722000","affected_rows":0,"status":"succ"}]}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.win_cpu_windows_1_Processor' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","f_percent_dpc_time","f_percent_idle_time","f_percent_interrupt_time","f_percent_privileged_time","f_percent_processor_time","f_percent_user_time"],"data":[["2019-08-01 14:42:02.000",0.000000000,95.598305000,0.000000000,0.000000000,0.000000000,0.000000000]],"rows":1}@ then + return -1 +endi + +print =============== step3 - multi-query data +system_content curl -u root:taosdata -d '{"metrics": [{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"window1","instance":"1","objectname":"Processor"},"timestamp":1564641723000},{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"window2","instance":"1","objectname":"Processor"},"timestamp":1564641723000}]}' 127.0.0.1:6020/telegraf/db/ + +print $system_content + +if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_window1_1_Processor","timestamp":"1564641723000","affected_rows":1,"status":"succ"},{"metric":"win_cpu","stable":"win_cpu","table":"win_cpu_window2_1_Processor","timestamp":"1564641723000","affected_rows":1,"status":"succ"}]}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select * from db.win_cpu_window1_1_Processor' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["ts","f_percent_dpc_time","f_percent_idle_time","f_percent_interrupt_time","f_percent_privileged_time","f_percent_processor_time","f_percent_user_time"],"data":[["2019-08-01 14:42:03.000",0.000000000,95.598305000,0.000000000,0.000000000,0.000000000,0.000000000]],"rows":1}@ then + return -1 +endi + +system_content curl -u root:taosdata -d 'select count(*) from db.win_cpu' 127.0.0.1:6020/rest/sql/ + +print $system_content + +if $system_content != @{"status":"succ","head":["count(*)"],"data":[[3]],"rows":1}@ then + return -1 +endi + diff --git a/tests/script/general/http/telegrafTest.go b/tests/script/general/http/telegrafTest.go new file mode 100644 index 0000000000..b8cbb43ce8 --- /dev/null +++ b/tests/script/general/http/telegrafTest.go @@ -0,0 +1,223 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" + "io/ioutil" + "net/http" + "os" + "sync" + "sync/atomic" + "time" + "flag" +) + +var ( + token string + url string + config Config + request int64 + period int64 + errorNum int64 + template string +) + +type Config struct { + HostIp string `json:"hostIp"` + MachineNum int `json:"machineNum"` + LoopNum int `json:"loopNum"` + DbName string `json:"dbName"` + DataBegin int64 `json:"dataBegin"` +} + +type TokenResult struct { + Status string `json:"status"` + Code int `json:"code"` + Desc string `json:"desc"` +} + +type JsonResult struct { + Status string `json:"status"` + Code int `json:"code"` +} + +func readConf(filename string) { + file, err := os.Open(filename) + if err != nil { + println("%s not found", filename) + panic(err) + } + defer file.Close() + + dec := json.NewDecoder(file) + err = dec.Decode(&config) + if err != nil { + println("%s parse error", filename) + panic(err) + } + + request = 0 + period = 0 + errorNum = 0 + + fmt.Println("================config parameters======================") + fmt.Println("HostIp:", config.HostIp) + fmt.Println("MachineNum:", config.MachineNum) + fmt.Println("LoopNum:", config.LoopNum) + fmt.Println("dbName:", config.DbName) + fmt.Println("dataBegin:", config.DataBegin) + + fmt.Println("================http token=============================") + token, err = getToken() + url = fmt.Sprintf("http://%s:%d/telegraf/%s", config.HostIp, 6020, config.DbName) + + fmt.Println("httpToken:", token) + fmt.Println("httpUrl:", url) + + if err != nil { + panic(err) + } +} + +func readReq(filename string) { + file, err := os.Open(filename) + if err != nil { + println("%s not found", filename) + panic(err) + } + defer file.Close() + + data, _ := ioutil.ReadAll(file) + + template = string(data[:]) + + //fmt.Println(template) +} + +func getToken() (string, error) { + resp, err := http.Get(fmt.Sprintf("http://%s:%d/rest/login/%s/%s", config.HostIp, 6020, "root", "taosdata")) + if err != nil { + return "", err + } + + defer resp.Body.Close() + + var tokenResult TokenResult + + data, err := ioutil.ReadAll(resp.Body) + + if err != nil { + return "", err + } + + err = json.Unmarshal(data, &tokenResult) + if err != nil { + return "", err + } + + if tokenResult.Status != "succ" { + fmt.Println("get http token failed") + fmt.Println(tokenResult) + return "", err + } + + return tokenResult.Desc, nil +} + +func exec(client *http.Client, sql string) { + for times := 0; times < 10; times++ { + + req, err1 := http.NewRequest("POST", url, bytes.NewReader([]byte(sql))) + if err1 != nil { + continue + } + req.Header.Add("Authorization", "Taosd "+token) + + begin := time.Now() + resp, err := client.Do(req) + + if err != nil { + continue + } + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Println(data) + resp.Body.Close() + continue + } + + spend := (time.Since(begin).Nanoseconds()) + + var jsonResult JsonResult + err = json.Unmarshal(data, &jsonResult) + if err != nil { + fmt.Println("parse json error: ", string(data[:])) + resp.Body.Close() + continue + } + + + atomic.AddInt64(&request, 1) + atomic.AddInt64(&period, spend) + + if request%1000 == 0 && request != 0 { + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.MachineNum) + dps := qps * float64(22) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) + } + return + } + //fmt.Println("xxxx>sql:", sql, ", retryTimes:", 10) + fmt.Println("exec sql failed") + errorNum++ +} + +func writeData(wg *sync.WaitGroup, tbIndex int) { + defer wg.Done() + client := &http.Client{} + + tbName := fmt.Sprintf("t%d", tbIndex) + + for j := 0; j < config.LoopNum; j++ { + tmVal := fmt.Sprintf("%d", int64(j)*int64(10000) + config.DataBegin) + //fmt.Println(tmVal) + + req1 := strings.Replace(template, "panshi-gsl", tbName, -1) + req2 := strings.Replace(req1, "1536750390000", tmVal, -1) + + //fmt.Println(req2) + exec(client, req2) + } +} + +func main() { + filename := flag.String("config", "telegraf.json", "config file name") + + flag.Parse() + + readReq("telegraf.req") + + readConf(*filename) + + fmt.Println("\n================telegraf test start======================") + + var wg sync.WaitGroup + + for i := 0; i < config.MachineNum; i++ { + wg.Add(1) + go writeData(&wg, i) + } + + wg.Wait() + + fmt.Println("\n================telegraf test stop ======================") + + requestAvg := float64(period) / float64(1000000) / float64(request) + qps := float64(1000) / float64(requestAvg) * float64(config.MachineNum) + dps := qps * float64(22) + fmt.Println("====== req:", request, ", error:", errorNum, ", qps:", int64(qps), ", wait:", int64(requestAvg), "ms", ", data per second:", int64(dps)) +} diff --git a/tests/script/general/http/telegraf_help.txt b/tests/script/general/http/telegraf_help.txt new file mode 100644 index 0000000000..a2e6d6e49c --- /dev/null +++ b/tests/script/general/http/telegraf_help.txt @@ -0,0 +1,24 @@ +1.±àÒë +½«main.go±àÒë³É¿ÉÖ´ÐÐÎļþ£¬telegrafTest +2.Ö´ÐÐ +./telegrafTest +3.²ÎÊý telegraf.jsonµÄÅäÖÃÎļþ + hostIp TDengine»úÆ÷IPµØÖ· + machineNum Ä£ÄâµÄ»úÆ÷ÊýÁ¿ + loopNum ÿ¸ö»úÆ÷·¢ËÍÇëÇóµÄ´ÎÊý + dbName ´´½¨µÄÊý¾Ý¿âÃû³Æ + dataBegin Éú³ÉÄ£ÄâÊý¾ÝµÄ¿ªÊ¼Ê±¼ä´Á +4.telegraf.req£¨Í¨³£²»±ä£© + 1£©Ìæ»»panshi-gslºÍ1536750380000ÕâÁ½¸ö×Ö·û´®£¬Éú³ÉhttpÇëÇó + 2£©Í¨¹ýhttp·¢Ë͸øTDengine +5.×¢Òâ + 1£©ÐÞ¸ÄÅäÖÃÎļþ/etc/taos/taos.cfg + httpDebugFlag ÉèÖÃΪ131£¨131-httpDebug,135-httpDebug£© + httpMaxThreads °´ÕÕ»úÆ÷Çé¿öÉèÖã¬ÉèÖ÷¶Î§Îª£¨1-cpu cores) + httpCacheSessions ÉèÖÃΪ¿ÉÄܵÄhttpÁ¬½ÓµÄ2±¶ + maxVnodeConnections ÉèÖÃΪ100000 + maxMeterConnections ÉèÖÃΪ100000 + maxShellConns ÉèÖÃΪ100000 + maxMgmtConnections ÉèÖÃΪ100000 + 2£©ÉèÖÃlinux²ÎÊý£¬ÀýÈç + ulimit -n 600000 \ No newline at end of file diff --git a/tests/script/general/http/testSuite.sim b/tests/script/general/http/testSuite.sim new file mode 100644 index 0000000000..9c50a60f78 --- /dev/null +++ b/tests/script/general/http/testSuite.sim @@ -0,0 +1,7 @@ +run lite/http/grafana.sim +run lite/http/restful.sim +run lite/http/restful_full.sim +run lite/http/telegraf.sim +run lite/http/prepare.sim +run lite/http/grafana_bug.sim +#run lite/http/opentsdb.sim diff --git a/tests/script/general/import/basic.sim b/tests/script/general/import/basic.sim new file mode 100644 index 0000000000..018d9ea7f7 --- /dev/null +++ b/tests/script/general/import/basic.sim @@ -0,0 +1,156 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database ibadb +sql use ibadb +sql create table tb(ts timestamp, i int) + +print ================= step1 + +sql import into tb values(1564641710000, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1564641708000, 8000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1564641720000, 20000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step4 +sql import into tb values(1564641708000, 8000) +sql import into tb values(1564641715000, 15000) +sql import into tb values(1564641730000, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1564641708000, 8000) +sql insert into tb values(1564641714000, 14000) +sql insert into tb values(1564641725000, 25000) +sql insert into tb values(1564641740000, 40000) +sql select * from tb; +if $rows != 6 then + return -1 +endi + +print ================= step6 +sql import into tb values(1564641707000, 7000) +sql import into tb values(1564641712000, 12000) +sql import into tb values(1564641723000, 23000) +sql import into tb values(1564641734000, 34000) +sql import into tb values(1564641750000, 50000) +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================= step7 +sql import into tb values(1564641707001, 7001) +sql import into tb values(1564641712001, 12001) +sql import into tb values(1564641723001, 23001) +sql import into tb values(1564641734001, 34001) +sql import into tb values(1564641750001, 50001) +sql select * from tb; +if $rows != 16 then + return -1 +endi + +print ================= step8 +sql insert into tb values(1564641708002, 8002) +sql insert into tb values(1564641714002, 14002) +sql insert into tb values(1564641725002, 25002) +sql insert into tb values(1564641900000, 200000) +sql select * from tb; +if $rows != 17 then + return -1 +endi + +print ================= step9 only insert last one +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 700000) +sql select * from tb; +if $rows != 20 then + return -1 +endi + +print ================= step10 +sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 70000) +sql select * from tb; +if $rows != 20 then + return -1 +endi + +print ================= step11 +sql import into tb values(1564642400000, 700000) +sql select * from tb; +if $rows != 20 then + return -1 +endi + +print ================= step12 +sql import into tb values(1564641709527, 9527)(1564641709527, 9528) +sql select * from tb; +print rows=> $rows +if $rows != 21 then + return -1 +endi + +print ================= step13 +sql import into tb values(1564641709898, 9898)(1564641709897, 9897) +sql select * from tb; +print rows=> $rows +if $rows != 23 then + return -1 +endi + diff --git a/tests/script/general/import/commit.sim b/tests/script/general/import/commit.sim new file mode 100644 index 0000000000..974d9e394f --- /dev/null +++ b/tests/script/general/import/commit.sim @@ -0,0 +1,103 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ========= step1 +sql create database ic1db days 7; +sql create table ic1db.tb(ts timestamp, s int); +sql insert into ic1db.tb values(now-30d, -30); +sql insert into ic1db.tb values(now-20d, -20); +sql insert into ic1db.tb values(now-10d, -10); +sql insert into ic1db.tb values(now-5d, -5); +sql insert into ic1db.tb values(now+1m, 1); +sql insert into ic1db.tb values(now+2m, 2); +sql insert into ic1db.tb values(now+3m, 6); +sql insert into ic1db.tb values(now+4m, 8); +sql insert into ic1db.tb values(now+5m, 10); +sql insert into ic1db.tb values(now+6m, 12); +sql insert into ic1db.tb values(now+7m, 14); +sql insert into ic1db.tb values(now+8m, 16); +sql select * from ic1db.tb; +if $rows != 12 then + return -1 +endi + +print ========= step2 +sql create database ic2db days 7; +sql create table ic2db.tb(ts timestamp, s int); +sql insert into ic2db.tb values(now, 0); +sql import into ic2db.tb values(now-30d, -30); +sql import into ic2db.tb values(now-20d, -20); +sql import into ic2db.tb values(now-10d, -10); +sql import into ic2db.tb values(now-5d, -5); +sql import into ic2db.tb values(now+1m, 1); +sql import into ic2db.tb values(now+2m, 2); +sql import into ic2db.tb values(now+3m, 6); +sql import into ic2db.tb values(now+4m, 8); +sql import into ic2db.tb values(now+5m, 10); +sql import into ic2db.tb values(now+6m, 12); +sql import into ic2db.tb values(now+7m, 14); +sql import into ic2db.tb values(now+8m, 16); +sql select * from ic2db.tb; +if $rows != 13 then + return -1 +endi + +print ========= step3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 + +print ========= step4 +sql select * from ic2db.tb; +if $rows != 13 then + return -1 +endi + +sql select * from ic1db.tb; +if $rows != 12 then + return -1 +endi + + + + diff --git a/tests/script/general/import/large.sim b/tests/script/general/import/large.sim new file mode 100644 index 0000000000..9fa8f66299 --- /dev/null +++ b/tests/script/general/import/large.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database db +sql use db +sql create table tb1(ts timestamp, i int, j float, k double) + +print ================= step1 + +$i = 0 +$timestamp = 1564641700000 +while $i < 1000 + + $val = 10 * $i + $val = $val + 2 + $ts = $timestamp + 200 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 3 + $ts = $timestamp + 300 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 4 + $ts = $timestamp + 400 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 5 + $ts = $timestamp + 500 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 6 + $ts = $timestamp + 600 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 7 + $ts = $timestamp + 700 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 8 + $ts = $timestamp + 800 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 9 + $ts = $timestamp + 900 + sql insert into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 1 + $ts = $timestamp + 100 + sql import into tb1 values ( $ts , $val , $val , $val ) + + $val = 10 * $i + $val = $val + 0 + $ts = $timestamp + 0 + sql import into tb1 values ( $ts , $val , $val , $val ) + + $timestamp = $timestamp + 1000 + $i = $i + 1 +endw + +print ================= step2 \ No newline at end of file diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim new file mode 100644 index 0000000000..62fb5e78d4 --- /dev/null +++ b/tests/script/general/import/replica1.sim @@ -0,0 +1,176 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create database ir1db days 7 +sql use ir1db +sql create table tb(ts timestamp, i int) + +print ================= step1 +sql import into tb values(now+10000a, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(now+8000a, 8000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step3 +sql insert into tb values(now+20000a, 20000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step4 +sql import into tb values(now+8000a, 9000) +sql import into tb values(now+15000a, 15000) +sql import into tb values(now+30000a, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(now+8000a, 8000) +sql insert into tb values(now+14000a, 14000) +sql insert into tb values(now+25000a, 25000) +sql insert into tb values(now+40000a, 40000) +sql select * from tb; +if $rows != 6 then + return -1 +endi + +print ================= step6 +sql import into tb values(now+7000a, 7000) +sql import into tb values(now+12000a, 12000) +sql import into tb values(now+23000a, 23000) +sql import into tb values(now+34000a, 34000) +sql import into tb values(now+50000a, 50000) +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================== dnode restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 + +sql use ir1db +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================= step7 +sql import into tb values(now+7001a, 7001) +sql import into tb values(now+12001a, 12001) +sql import into tb values(now+23001a, 23001) +sql import into tb values(now+34001a, 34001) +sql import into tb values(now+50001a, 50001) +sql select * from tb; +if $rows != 16 then + return -1 +endi + +print ================= step8 +sql insert into tb values(now+8002a, 8002) +sql insert into tb values(now+14002a, 14002) +sql insert into tb values(now+25002a, 25002) +sql insert into tb values(now+200000a, 60000) +sql select * from tb; +if $rows != 17 then + return -1 +endi + +print ================= step9 +sql import into tb values(now-30d, 7003) +sql import into tb values(now-20d, 34003) +sql import into tb values(now-10d, 34003) +sql import into tb values(now-5d, 34003) +sql import into tb values(now+1m, 50001) +sql import into tb values(now+2m, 50001) +sql import into tb values(now+3m, 50001) +sql import into tb values(now+4m, 50002) +sql import into tb values(now+5m, 50003) +sql import into tb values(now+6m, 50004) +sql import into tb values(now+7m, 50001) +sql import into tb values(now+8m, 500051) +sql select * from tb; +if $rows != 29 then + return -1 +endi + +print ================= step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 + +sql use ir1db +sql select * from tb; +if $rows != 29 then + return -1 +endi + +print ================= step11 +sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql select * from tb; +if $rows != 34 then + return -1 +endi + +sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +sql select * from tb; +if $rows != 43 then + return -1 +endi + + + + diff --git a/tests/script/general/import/testSuite.sim b/tests/script/general/import/testSuite.sim new file mode 100644 index 0000000000..51b652f9c1 --- /dev/null +++ b/tests/script/general/import/testSuite.sim @@ -0,0 +1,4 @@ +run lite/import/basic.sim +#run lite/import/commit.sim +run lite/import/large.sim +run lite/import/replica1.sim diff --git a/tests/script/general/insert/basic.sim b/tests/script/general/insert/basic.sim new file mode 100644 index 0000000000..3b18c7e23a --- /dev/null +++ b/tests/script/general/insert/basic.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_in_db +$tbPrefix = tb_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$x = 0 +while $x < 10 + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +print =============== step 2 +sql insert into $tb values (now - 5m , 10) -x error_insert +sql insert into $tb values (now - 6m , 10) -x error_insert +sql insert into $tb values (now - 7m , 10) -x error_insert +sql insert into $tb values (now - 8m , 10) -x error_insert +error_insert: + +sql select * from $tb + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim new file mode 100644 index 0000000000..ef183bb2f0 --- /dev/null +++ b/tests/script/general/insert/insert_drop.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== insert_drop.sim +$i = 0 +$db = iddb +$stb = stb + +sql drop database $db -x step1 +step1: +sql create database $db tables 10 ctime 30 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < 10 + $tb = tb . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +print ====== tables created + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +sql use $db +sql drop table tb5 + +while $i < 4 + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +sql use $db +sql create table tb5 using $stb tags(5) +sql select * from tb5 +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/insert/query_block1_file.sim b/tests/script/general/insert/query_block1_file.sim new file mode 100644 index 0000000000..dff250ba8b --- /dev/null +++ b/tests/script/general/insert/query_block1_file.sim @@ -0,0 +1,195 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_1f_db +$tbPrefix = tb_1f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$R = 4 +$x = $N * 2 +$y = $N * $R +$expect = $y + $N +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 3 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/general/insert/query_block1_memory.sim new file mode 100644 index 0000000000..b94eb4ecd1 --- /dev/null +++ b/tests/script/general/insert/query_block1_memory.sim @@ -0,0 +1,177 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_1m_db +$tbPrefix = tb_1m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/insert/query_block2_file.sim b/tests/script/general/insert/query_block2_file.sim new file mode 100644 index 0000000000..3ce1e51e02 --- /dev/null +++ b/tests/script/general/insert/query_block2_file.sim @@ -0,0 +1,210 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_2f_db +$tbPrefix = tb_2f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows +$N = 82 + +print =============== step 1 +$x = $N * 2 +$y = $N +$expect = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$R = 4 +$y = $N * $R + +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x + +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$N2 = $N +$result1 = $N +$result2 = 2 * $N +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/insert/query_block2_memory.sim b/tests/script/general/insert/query_block2_memory.sim new file mode 100644 index 0000000000..6546d89507 --- /dev/null +++ b/tests/script/general/insert/query_block2_memory.sim @@ -0,0 +1,172 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_2m_db +$tbPrefix = tb_2m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$N = 82 + +$x = $N * 2 +$y = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 + +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/insert/query_file_memory.sim b/tests/script/general/insert/query_file_memory.sim new file mode 100644 index 0000000000..d968f1b1f8 --- /dev/null +++ b/tests/script/general/insert/query_file_memory.sim @@ -0,0 +1,209 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_fm_db +$tbPrefix = tb_fm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows + +$N = 82 + +$x = $N * 2 +$y = $N +$expect = $y +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$R = 4 +$R = $R - 1 + +$y = $N * $R +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/general/insert/query_multi_file.sim b/tests/script/general/insert/query_multi_file.sim new file mode 100644 index 0000000000..802efe2ac1 --- /dev/null +++ b/tests/script/general/insert/query_multi_file.sim @@ -0,0 +1,55 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = tb_mf_db +$tbPrefix = tb_mf_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +$N = 20000 + +$x = 0 + +while $x < $N + $ms = $x . s + #print insert into $tb values (now + $ms , $x ) + sql insert into $tb values (now + $ms , $x ) -x error_insert + $x = $x + 1 +endw +error_insert: + +sql select * from $tb +print $rows points data are retrieved -> exepct $N rows +if $rows < $N then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/insert/tcp.sim b/tests/script/general/insert/tcp.sim new file mode 100644 index 0000000000..ecb6dc43d5 --- /dev/null +++ b/tests/script/general/insert/tcp.sim @@ -0,0 +1,40 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +sql create database d1; +sql create table d1.t1(ts timestamp, test binary(1000)); +sql insert into d1.t1 values (now , '1' ) + +sql create database d2; +sql create table d2.t2(ts timestamp, test binary(1000)); +sql insert into d2.t2 values (now , '1' ) + +sql create database db +sql use db +sql create table tb (ts timestamp, test binary(1000)) + + +$x = 0 +while $x < 10000 + $ms = $x . s + sql insert into tb values (now + $ms , '1' ) + $x = $x + 1 +endw + +sql select * from tb + + +return + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/insert/testSuite.sim b/tests/script/general/insert/testSuite.sim new file mode 100644 index 0000000000..1048e179e7 --- /dev/null +++ b/tests/script/general/insert/testSuite.sim @@ -0,0 +1,8 @@ +run lite/insert/basic.sim +run lite/insert/insert_drop.sim +run lite/insert/query_block1_memory.sim +run lite/insert/query_block2_memory.sim +run lite/insert/query_block1_file.sim +run lite/insert/query_block2_file.sim +run lite/insert/query_file_memory.sim +run lite/insert/query_multi_file.sim diff --git a/tests/script/general/metrics/disk.sim b/tests/script/general/metrics/disk.sim new file mode 100644 index 0000000000..a960fd96fa --- /dev/null +++ b/tests/script/general/metrics/disk.sim @@ -0,0 +1,197 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = d_db +$tbPrefix = d_tb +$mtPrefix = d_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sql select count(*) from $mt +print select count(*) from $mt ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 6000 + +sql use $db +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print select count(*) from $mt ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print select count(tbcol) as b from $mt interval(1m) ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data02 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +print select count(tbcol) as b from $mt group by tgcol +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/metrics/metrics.sim b/tests/script/general/metrics/metrics.sim new file mode 100644 index 0000000000..0aabadd0e4 --- /dev/null +++ b/tests/script/general/metrics/metrics.sim @@ -0,0 +1,137 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_me_db +$tbPrefix = m_me_tb +$mtPrefix = m_me_mt + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db + +sql create table $mt (ts timestamp, speed int) TAGS(sp int) +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql drop table $mt +sql show stables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $mt (ts timestamp, speed int) TAGS(sp int) + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 0 then + return -1 +endi +sql select * from $mt +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(1) +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(2) +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags(3) + +sql show tables +if $rows != 3 then + return -1 +endi +if $data03 != $mt then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +print =============== step5 +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values (now + 1m , 1 ) + +print sleep 8000 +sleep 8000 + +print =============== step6 + +sql select * from $mt +print select * from $mt ==> $rows $data00 +if $rows != 3 then + return -1 +endi + +print =============== step7 +sql select * from $mt where sp = 1 +print select * from $mt where sp = 1 ==> $rows $data00 +if $rows != 1 then + return -1 +endi + +print =============== step8 +sql drop table $mt + +print =============== step9 + +sql show tables +if $rows != 0 then + return -1 +endi + +sql show stables +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/metrics/testSuite.sim b/tests/script/general/metrics/testSuite.sim new file mode 100644 index 0000000000..7f23e30823 --- /dev/null +++ b/tests/script/general/metrics/testSuite.sim @@ -0,0 +1,4 @@ +run lite/metrics/disk.sim +run lite/metrics/metrics.sim +run lite/metrics/values.sim +run lite/metrics/vnode3.sim diff --git a/tests/script/general/metrics/values.sim b/tests/script/general/metrics/values.sim new file mode 100644 index 0000000000..e91a9fee39 --- /dev/null +++ b/tests/script/general/metrics/values.sim @@ -0,0 +1,126 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +sql create database vdb0 +sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +sql create table vdb0.vtb00 using vdb0.mt tags( 0 ) +sql create table vdb0.vtb01 using vdb0.mt tags( 0 ) + +sql create database vdb1 +sql create table vdb1.vtb10 using vdb0.mt tags( 1 ) +sql create table vdb1.vtb11 using vdb0.mt tags( 1 ) + +sql create database vdb2 +sql create table vdb2.vtb20 using vdb0.mt tags( 2 ) +sql create table vdb2.vtb21 using vdb0.mt tags( 2 ) + +sql create database vdb3 +sql create table vdb3.vtb30 using vdb0.mt tags( 3 ) +sql create table vdb3.vtb31 using vdb0.mt tags( 3 ) + +print =============== step2 +sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30) +sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31) +sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32) +sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33) +sql select * from vdb0.mt + +if $rows != 24 then + return -1 +endi + +print =============== step3 +sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60) +sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61) +sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62) +sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63) +sql select * from vdb0.mt + +if $rows != 48 then + return -1 +endi + +print =============== step4 +sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70) +sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71) +sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72) +sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73) +sql select * from vdb0.mt + +if $rows != 64 then + return -1 +endi + +print =============== step5 +sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70) +sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71) +sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72) +sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73) +sql select * from vdb0.mt + +if $rows != 68 then + return -1 +endi + +print =============== step6 +sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100) +sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100) + +sql select * from vdb0.mt + +if $rows != 84 then + return -1 +endi + +print =============== step7 +sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110) +sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110) + +sql select * from vdb0.mt + +if $rows != 100 then + return -1 +endi + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/script/general/metrics/vnode3.sim b/tests/script/general/metrics/vnode3.sim new file mode 100644 index 0000000000..3a5c58363e --- /dev/null +++ b/tests/script/general/metrics/vnode3.sim @@ -0,0 +1,178 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = v3_db +$tbPrefix = v3_tb +$mtPrefix = v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/README.txt b/tests/script/general/parser/README.txt new file mode 100644 index 0000000000..1072976380 --- /dev/null +++ b/tests/script/general/parser/README.txt @@ -0,0 +1,27 @@ +This file contains a brief info about the parser test scripts directory. + +The directory contains scripts for TDengine parser testing, mainly focus on syntax parsing and datatype support. The tests are organized in the way database languages are catagorized. + +DML: +{ +SELECT +INSERT +INTERVAL +FILL +DESCRIBE +SHOW +} + +DDL: +{ +CREATE DATABASE/METRIC/TABLE +DROP DATABASE/METRIC/TABLE +} + +DCL: +{ +CREATE ACCOUNT/USER +DROP ACCOUNT/USER +*ALTER USER PRIVILEGE +} + diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim new file mode 100644 index 0000000000..87e4089d35 --- /dev/null +++ b/tests/script/general/parser/alter.sim @@ -0,0 +1,241 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 3 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 3 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_alt_db +$tbPrefix = m_alt_tb +$mtPrefix = m_alt_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db +sql use $db +##### alter table test, simeplest case +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql alter table tb drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +sql alter table tb add column c3 nchar(4) +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +print data03 = $data03 +if $data03 != taos then + return -1 +endi +sql drop table tb + +##### alter metric test, simplest case +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != null then + return -1 +endi +sql insert into tb values (now, 2, 2, 'taos') +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data03 != taos then + return -1 +endi +if $data13 != null then + return -1 +endi +sql drop table tb +sql drop table mt + +## [TBASE272] +sql create table tb (ts timestamp, c1 int, c2 int, c3 int) +sql insert into tb values (now, 1, 1, 1) +sql alter table tb drop column c3 +sql alter table tb add column c3 nchar(5) +sql insert into tb values(now, 2, 2, 'taos') +sql drop table tb +sql create table mt (ts timestamp, c1 int, c2 int, c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sql insert into tb values (now, 1, 1, 1) +sql alter table mt drop column c3 +sql select * from tb order by ts desc +if $rows != 1 then + return -1 +endi +sql drop table tb +sql drop table mt + +sleep 3000 +## ALTER TABLE WHILE STREAMING [TBASE271] +sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int) +sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s) +sql select * from strm +if $rows != 0 then + return -1 +endi +#sleep 12000 +sql insert into tb1 values (now, 1, 'taos', 1) +sleep 20000 +sql select * from strm +print rows = $rows +if $rows != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +sql alter table tb1 drop column c3 +sleep 6000 +sql insert into tb1 values (now, 2, 'taos') +sleep 3000 +sql select * from strm +if $rows != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +sql alter table tb1 add column c3 int +sleep 6000 +sql insert into tb1 values (now, 3, 'taos', 3); +sleep 3000 +sql select * from strm +if $rows != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +## ALTER TABLE AND INSERT BY COLUMNS +sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table tb using mt tags(0) +sql insert into tb values (now-1m, 1, 1) +sql alter table mt drop column c2 +sql_error insert into tb (ts, c1, c2) values (now, 2, 2) +sql insert into tb (ts, c1) values (now, 2) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != null then + return -1 +endi +sql alter table mt add column c2 int +sql insert into tb (ts, c2) values (now, 3) +sql select * from tb order by ts desc +if $data02 != 3 then + return -1 +endi + +## ALTER TABLE AND IMPORT +sql drop database $db +sql create database $db +sql use $db +sql create table mt (ts timestamp, c1 int, c2 nchar(7), c3 int) tags (t1 int) +sql create table tb using mt tags(1) +sleep 3000 +sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) +sql alter table mt drop column c3 +# the below query should be deleted after bug fix +sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert') +sql_error import into tb values ('2018-11-01 16:29:59.000', 1, 'import') +sql select * from tb order by ts desc +if $data01 != 1 then + return -1 +endi +if $data02 != insert then + return -1 +endi +sql alter table mt add column c3 nchar(4) +sql select * from tb order by ts desc +if $data03 != null then + return -1 +endi +# the query below should be deleted after bug fix +sql reset query cache +sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql_error import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3) +sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3) +sql select * from tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data03 != 3 then + return -1 +endi + +##### ILLEGAL OPERATIONS + +# try dropping columns that are defined in metric +sql_error alter table tb drop column c1; + +# try dropping primary key +sql_error alter table mt drop column ts; + +# try modifying two columns in a single statement +sql_error alter table mt add column c5 nchar(3) c6 nchar(4) + +# duplicate columns +sql_error alter table mt add column c1 int + +# drop non-existing columns +sql_error alter table mt drop column c9 + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/alter1.sim b/tests/script/general/parser/alter1.sim new file mode 100644 index 0000000000..695003c702 --- /dev/null +++ b/tests/script/general/parser/alter1.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +sql reset query cache + +$dbPrefix = alt1_db + +print ========== alter1.sim +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db + +sql create table stb (ts timestamp, speed double, mileage double) tags(carId int, carModel int) +sql create table car1 using stb tags (1, 1) +sql create table car2 using stb tags (2, 1) +sql create table car3 using stb tags (3, 2) +sql insert into car1 values (now-1s, 100, 10000) +sql insert into car2 values (now, 100, 10000) +sql insert into car3 values (now, 100, 10000) +sql insert into car1 values (now, 120, 11000) +print ================== add a column +sql alter table stb add column c1 int +sql describe stb +if $rows != 6 then + return -1 +endi + +sql select * from stb +print rows = $rows +if $rows != 4 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data23 != null then + return -1 +endi +if $data33 != null then + return -1 +endi + +sql select c1 from stb +if $rows != 4 then + return -1 +endi +if $data00 != null then + return -1 +endi +if $data30 != null then + return -1 +endi + +sql select c1+speed from stb +if $rows != 4 then + return -1 +endi + +sql select c1+speed from car1 +if $rows != 2 then + return -1 +endi +if $data00 != null then + return -1 +endi +if $data10 != null then + return -1 +endi + +sql select * from car1 +if $rows != 2 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data13 != null then + return -1 +endi + +sleep 3000 +print ================== insert values into table +sql insert into car1 values (now, 1, 1,1 ) (now +1s, 2,2,2,) car2 values (now, 1,3,3) + +sql select c1+speed from stb where c1 > 0 +if $rows != 3 then + return -1 +endi + +print ================== add a tag +sql alter table stb add tag t1 int +sql describe stb +if $rows != 7 then + return -1 +endi +if $data60 != t1 then + return -1 +endi + +print ================== change a tag value +sql alter table car1 set tag carid=10 +sql describe car1 +if $rows != 7 then + return -1 +endi +if $data43 != 10 then + return -1 +endi + +sql select * from stb where carid = 10 +if $rows != 4 then + return -1 +endi + +sql alter table car2 set tag carmodel = 2 +sql select * from stb where carmodel = 2 +print $rows +if $rows != 3 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/alter_stable.sim b/tests/script/general/parser/alter_stable.sim new file mode 100644 index 0000000000..6ef9b812e7 --- /dev/null +++ b/tests/script/general/parser/alter_stable.sim @@ -0,0 +1,43 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 3 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 3 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ========== alter_stable.sim + +$db = demodb +sql drop database if exists $db +sql create database $db +sql use $db + +##### alter stable test : change tag name +# case-1 change tag name: new name inclue old name +sql create table mt1 (ts timestamp, c1 int) tags (a int) +sql alter table mt1 change tag a abcd +sql alter table mt1 change tag abcd a +sql_error alter table mt1 change tag a 1 + +sql_error create table mtx1 (ts timestamp, c1 int) tags (123 int) + +sql create table mt2 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789def int) +sql create table mt3 (ts timestamp, c1 int) tags (abc012345678901234567890123456789012345678901234567890123456789 int) +sql_error alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg012345678901234567890123456789012345678901234567890123456789 +sql alter table mt3 change tag abc012345678901234567890123456789012345678901234567890123456789 abcdefg0123456789012345678901234567890123456789 + +# case-2 set tag value +sql create table mt4 (ts timestamp, c1 int) tags (name binary(16), len int) +sql create table tb1 using mt4 tags ("beijing", 100) +sql alter table tb1 set tag name = "shanghai" +sql alter table tb1 set tag name = "" +sql alter table tb1 set tag name = "shenzhen" +sql alter table tb1 set tag len = 379 + +# test end +sql drop database $db + + diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim new file mode 100644 index 0000000000..ed3131d2ac --- /dev/null +++ b/tests/script/general/parser/auto_create_tb.sim @@ -0,0 +1,306 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = ac_db +$tbPrefix = ac_tb +$stbPrefix = ac_stb +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 +$ts0 = 1537146000000 + +print excuting test script auto_create_tb.sim +print =============== set up +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +print =========== auto_create_tb.sim case1: test +sql CREATE TABLE $stb (TS TIMESTAMP, C1 INT, C2 BIGINT, C3 FLOAT, C4 DOUBLE, C5 BINARY(10), C6 BOOL, C7 SMALLINT, C8 TINYINT, C9 NCHAR(10)) TAGS (T1 INT) +sql show stables + +if $rows != 1 then + return -1 +endi +if $data00 != $stb then + return -1 +endi + +### create table on the fly +sql insert into tb1 using $stb tags (1) values ( $ts0 , 1,1,1,1,'bin',1,1,1,'涛æ€æ•°æ®') +sql select * from tb1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data09 != 涛æ€æ•°æ® then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != bin then + return -1 +endi + +### insert into an existing table +$ts1 = $ts0 + 1000 +$ts2 = $ts0 + 2000 +sql insert into tb1 using $stb tags (1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛æ€æ•°æ®') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 3 then + return -1 +endi +if $data19 != 涛æ€æ•°æ® then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data22 != 2 then + return -2 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data25 != binar then + return -1 +endi +if $data29 != nchar then + return -1 +endi + +### [TBASE-410] auto create table with a negative tag value +$ts1 = $ts0 + 1000 +$ts2 = $ts0 + 2000 +sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛æ€æ•°æ®') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 3 then + return -1 +endi +if $data19 != 涛æ€æ•°æ® then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data22 != 2 then + return -2 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data25 != binar then + return -1 +endi +if $data29 != nchar then + return -1 +endi +sql drop table tb_1 + +#### insert into an existing table with wrong tags +$ts3 = $ts0 + 3000 +$ts4 = $ts0 + 4000 +sql insert into tb1 using $stb tags (2) values ( $ts3 , 1,1,1,1,'bin',1,1,1,'涛æ€æ•°æ®') ( $ts4 , 2,2,2,2,'binar', 1,1,1,'nchar') +sql select * from $stb +if $rows != 5 then + return -1 +endi +if $data19 != 涛æ€æ•°æ® then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data22 != 2 then + return -2 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data25 != binar then + return -1 +endi +if $data29 != nchar then + return -1 +endi + +sql drop table tb1 + +#### auto create multiple tables +sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛æ€æ•°æ®1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛æ€æ•°æ®2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛æ€æ•°æ®3') +sql show tables +if $rows != 3 then + return -1 +endi +if $data00 != tb3 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb1 then + return -1 +endi + +sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 1 then + return -1 +endi +if $data08 != 涛æ€æ•°æ®1 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data18 != 涛æ€æ•°æ®2 then + return -1 +endi +if $data28 != 涛æ€æ•°æ®3 then + return -1 +endi + +sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 涛æ€æ•°æ®2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data11 != 涛æ€æ•°æ®3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 +sql use $db + +#### auto create multiple tables +sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛æ€æ•°æ®1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛æ€æ•°æ®2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛æ€æ•°æ®3') +sql show tables +if $rows != 3 then + return -1 +endi +if $data00 != tb3 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb1 then + return -1 +endi + +sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb +if $rows != 3 then + return -1 +endi +#if $data00 != @18-09-17 09:00:00.000@ then +# return -1 +#endi +if $data01 != 1 then + return -1 +endi +if $data08 != 涛æ€æ•°æ®1 then + return -1 +endi +if $data14 != 2.000000000 then + return -1 +endi +if $data18 != 涛æ€æ•°æ®2 then + return -1 +endi +if $data28 != 涛æ€æ•°æ®3 then + return -1 +endi + +sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 涛æ€æ•°æ®2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data11 != 涛æ€æ•°æ®3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi + +print ======= too many columns in auto create tables +sql create table tick (ts timestamp , last_prc double , volume int, amount double, oi int , bid_prc1 double, ask_prc1 double, bid_vol1 int, ask_vol1 int , bid_prc2 double, ask_prc2 double, bid_vol2 int, ask_vol2 int , bid_prc3 double, ask_prc3 double, bid_vol3 int, ask_vol3 int , bid_prc4 double, ask_prc4 double, bid_vol4 int, ask_vol4 int , bid_prc5 double, ask_prc5 double, bid_vol5 int, ask_vol5 int , open_prc double, highest_prc double, low_prc double, close_prc double , upper_limit double, lower_limit double) TAGS (ticker BINARY(32), product BINARY(8)); +sql show stables + +if $rows != 2 then + return -1 +endi + +sql insert into tick_000001 ('ts', 'last_prc', 'volume', 'amount', 'oi', 'bid_prc1', 'ask_prc1') using tick tags (000001, Stocks) VALUES (1546391700000, 0.000000, 0, 0.000000, 0, 0.000000, 10.320000); +sql select tbname from tick +if $rows != 1 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +#[tbase-673] +sql create table tu(ts timestamp, k int); +sql_error create table txu using tu tags(0) values(now, 1); + +#[TBASE-675] +sql insert into tu values(1565971200000, 1) (1565971200000,2) (1565971200001, 3)(1565971200001, 4) +if $rows != 2 then + return -1 +endi diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/general/parser/auto_create_tb_drop_tb.sim new file mode 100644 index 0000000000..3489aba9fd --- /dev/null +++ b/tests/script/general/parser/auto_create_tb_drop_tb.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c commitTime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 5 +$rowNum = 1361 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== auto_create_tb_drop_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db rows 200 cache 2048 tables 4 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $stb (ts timestamp, c1 int) tags (t1 binary(10)) +$x = 0 +$t = 0 +while $t < $tbNum + $t1 = 'tb . $t + $t1 = $t1 . ' + $tbname = tb . $t + print t = $t + print tbname = $tbname + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tbname using $stb tags( $t1 ) values ( $ts , $x ) + $x = $x + 1 + endw + $t = $t + 1 + $x = 0 +endw +print ====== tables created + +sleep 60000 + +sql drop table tb2 +$x = 0 +while $x < $rowNum + $ts = $ts + $delta + $t1 = 'tb . $t + $t1 = $t1 . ' + sql insert into tb1 using $stb tags( $t1 ) values ( $ts , $x ) + $x = $x + 1 +endw + +sleep 6000 + +$ts = $ts0 + $delta +$ts = $ts + 1 + +$x = 0 +while $x < 100 + $ts = $ts + $delta + sql insert into tb2 using stb0 tags('tb2') values ( $ts , 1) + sql select * from tb2 + $res = $x + 1 + if $rows != $res then + return -1 + endi + if $data01 != 1 then + return -1 + endi + $x = $x + 1 + print loop $x +endw diff --git a/tests/script/general/parser/binary_escapeCharacter.sim b/tests/script/general/parser/binary_escapeCharacter.sim new file mode 100644 index 0000000000..6ab86c5ba3 --- /dev/null +++ b/tests/script/general/parser/binary_escapeCharacter.sim @@ -0,0 +1,104 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 3 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 3 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql drop database if exists ecdb +sql create database ecdb +sql use ecdb + +sql create table tbx (ts timestamp, c1 int, c2 binary(20)) +sql insert into tbx values ('2019-10-05 18:00:01.000', 1, '\'') +sql insert into tbx values ('2019-10-05 18:00:02.000', 2, '\'abc') +sql insert into tbx values ('2019-10-05 18:00:03.000', 3, '123\'') +sql select * from tbx +print "=====rows:$rows, line0:$data02, line1:$data12, line2:$data22" +if $data02 != @'@ then + return -1 +endi + +if $data12 != @'abc@ then + return -1 +endi + +if $data22 != @123'@ then + return -1 +endi + +sql create table tb (ts timestamp, c1 binary(20)) +sql insert into tb values ('2019-10-05 18:00:01.000', 'abc''001') +sql insert into tb values ('2019-10-05 18:00:02.000', 'abc\'002') +sql insert into tb values ('2019-10-05 18:00:03.000', 'abc\\003') +sql insert into tb values ('2019-10-05 18:00:04.000', 'abc"004') +sql insert into tb values ('2019-10-05 18:00:05.000', 'abc\005') + +sql insert into tb values ('2019-10-05 18:00:06.000', "udp""001") +sql insert into tb values ('2019-10-05 18:00:07.000', "udp\"002") +sql insert into tb values ('2019-10-05 18:00:08.000', "udp\\003") +sql insert into tb values ('2019-10-05 18:00:09.000', "udp'004") +sql insert into tb values ('2019-10-05 18:00:10.000', "udp\005") + +sql select * from tb limit 5 +print "====rows: $rows " +if $rows != 5 then + return -1 +endi + +print "Single quotation ==== data01~05: $data01, $data11, $data21, $data31, $data41 " + +if $data01 != @abc'001@ then + return -1 +endi +if $data11 != @abc'002@ then + return -1 +endi +if $data21 != @abc\003@ then + #return -1 + print "[ERROR] expect: abc\003, act:$data21" +endi +if $data31 != @abc"004@ then + return -1 +endi +if $data41 != @abc005@ then + #return -1 + print "[ERROR] expect: abc005, act:$data41" +endi + +sql select * from tb limit 5 offset 5 + +if $rows != 5 then + return -1 +endi + +print "Double quotation ==== data01~05: $data01, $data11, $data21, $data31, $data41 " + +if $data01 != @udp"001@ then + return -1 +endi +if $data11 != @udp"002@ then + return -1 +endi +if $data21 != @udp\003@ then + # return -1 + print "[ERROR] expect: udp\003, act:$data21" +endi +if $data31 != @udp'004@ then + return -1 +endi +if $data41 != @udp005@ then + #return -1 + print "[ERROR] expect: udp005, act:$data41" +endi + + + + + + + + diff --git a/tests/script/general/parser/bug.sim b/tests/script/general/parser/bug.sim new file mode 100644 index 0000000000..cac74671f3 --- /dev/null +++ b/tests/script/general/parser/bug.sim @@ -0,0 +1,45 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c dDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c mDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c cDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c monitorDebugflag -v 135 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c uDebugFlag -v 135 + +system sh/cfg.sh -n dnode1 -c httpCacheSessions -v 10 +system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 10 +system sh/cfg.sh -n dnode1 -c httpEnableCompress -v 0 + +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 60 + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database db; +sql use db; +sql create table t (ts timestamp, i int); +sql create table st1 (ts timestamp, f1 int) tags(t1 int); +sql create table st2 (ts timestamp, f2 int) tags(t2 int); + +sql create table t1 using st1 tags(1); +sql create table t2 using st2 tags(1); + +sql insert into t1 values(1575880055000, 1); +sql insert into t2 values(1575880055000, 2); + +sql select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:6020/restful/sql + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim new file mode 100644 index 0000000000..5b478d7fc2 --- /dev/null +++ b/tests/script/general/parser/col_arithmetic_operation.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ca_db +$tbPrefix = ca_tb +$stbPrefix = ca_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== col_arithmetic_operation.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfTbNum = $tbNum / 2 +while $i < $halfTbNum + $tbId = $i + $halfTbNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +##### select from table +$tb = $tbPrefix . 0 +## TBASE-344 +sql select c1*2 from $tb +if $rows != $rowNum then + return -1 +endi +if $data00 != 0.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data90 != 18.000000000 then + return -1 +endi + +sql select c4*1+1/2 from $tb +if $rows != $rowNum then + return -1 +endi +if $data00 != 0.500000000 then + return -1 +endi +if $data10 != 1.500000000 then + return -1 +endi +if $data90 != 9.500000000 then + return -1 +endi + +#### illegal operations +sql_error select max(c2*2) from $tb +sql_error select 2*min(c1) from $tb +sql_error select max(c1-c2) from $tb diff --git a/tests/script/general/parser/columnValue.sim b/tests/script/general/parser/columnValue.sim new file mode 100644 index 0000000000..854bb219e5 --- /dev/null +++ b/tests/script/general/parser/columnValue.sim @@ -0,0 +1,37 @@ +#### +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 3 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 3 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +run lite/parser/columnValue_bool.sim +run lite/parser/columnValue_tinyint.sim +run lite/parser/columnValue_smallint.sim +run lite/parser/columnValue_int.sim +run lite/parser/columnValue_bigint.sim +run lite/parser/columnValue_float.sim +run lite/parser/columnValue_double.sim + + + + + + + + + + + + + diff --git a/tests/script/general/parser/columnValue_bigint.sim b/tests/script/general/parser/columnValue_bigint.sim new file mode 100644 index 0000000000..5a9e3d900a --- /dev/null +++ b/tests/script/general/parser/columnValue_bigint.sim @@ -0,0 +1,466 @@ +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: bigint +print ========== bigint +sql create table mt_bigint (ts timestamp, c bigint) tags (tagname bigint) + +## case 00: static create table for test tag values +sql create table st_bigint_0 using mt_bigint tags (null) +sql describe st_bigint_0 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_1 using mt_bigint tags (NULL) +sql describe st_bigint_1 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_2 using mt_bigint tags ('null') +sql describe st_bigint_2 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_3 using mt_bigint tags ('NULL') +sql describe st_bigint_3 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_4 using mt_bigint tags ("null") +sql describe st_bigint_4 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_5 using mt_bigint tags ("NULL") +sql describe st_bigint_5 +if $data23 != NULL then + return -1 +endi +sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807) +sql describe st_bigint_6 +if $data23 != -9223372036854775807 then + return -1 +endi +sql create table st_bigint_7 using mt_bigint tags (9223372036854775807) +sql describe st_bigint_7 +if $data23 != 9223372036854775807 then + return -1 +endi +sql create table st_bigint_8 using mt_bigint tags (37) +sql describe st_bigint_8 +if $data23 != 37 then + return -1 +endi +sql create table st_bigint_9 using mt_bigint tags (-100) +sql describe st_bigint_9 +if $data23 != -100 then + return -1 +endi +sql create table st_bigint_10 using mt_bigint tags (+113) +sql describe st_bigint_10 +if $data23 != 113 then + return -1 +endi +sql create table st_bigint_11 using mt_bigint tags ('-100') +sql describe st_bigint_11 +if $data23 != -100 then + return -1 +endi +sql create table st_bigint_12 using mt_bigint tags ("+78") +sql describe st_bigint_12 +if $data23 != 78 then + return -1 +endi +sql create table st_bigint_13 using mt_bigint tags (+0078) +sql describe st_bigint_13 +if $data23 != 78 then + return -1 +endi +sql create table st_bigint_14 using mt_bigint tags (-00078) +sql describe st_bigint_14 +if $data23 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_bigint_0 values (now, null) +sql select * from st_bigint_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_1 values (now, NULL) +sql select * from st_bigint_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_2 values (now, 'null') +sql select * from st_bigint_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_3 values (now, 'NULL') +sql select * from st_bigint_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_4 values (now, "null") +sql select * from st_bigint_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_5 values (now, "NULL") +sql select * from st_bigint_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_bigint_6 values (now, 9223372036854775807) +sql select * from st_bigint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 9223372036854775807 then + return -1 +endi +sql insert into st_bigint_7 values (now, -9223372036854775807) +sql select * from st_bigint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -9223372036854775807 then + return -1 +endi +sql insert into st_bigint_8 values (now, +100) +sql select * from st_bigint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_bigint_9 values (now, "-098") +sql select * from st_bigint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_bigint_10 values (now, '0') +sql select * from st_bigint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_11 values (now, -0) +sql select * from st_bigint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_12 values (now, "+056") +sql select * from st_bigint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_bigint_13 values (now, +056) +sql select * from st_bigint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_bigint_14 values (now, -056) +sql select * from st_bigint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_bigint_16 using mt_bigint tags (null) values (now, null) +sql describe st_bigint_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_16 +if $data01 != null then + return -1 +endi + +sql insert into st_bigint_17 using mt_bigint tags (NULL) values (now, NULL) +sql describe st_bigint_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_17 +if $data01 != null then + return -1 +endi +sql insert into st_bigint_18 using mt_bigint tags ('null') values (now, 'null') +sql describe st_bigint_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_18 +if $data01 != null then + return -1 +endi +sql insert into st_bigint_19 using mt_bigint tags ('NULL') values (now, 'NULL') +sql describe st_bigint_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_19 +if $data01 != null then + return -1 +endi +sql insert into st_bigint_20 using mt_bigint tags ("null") values (now, "null") +sql describe st_bigint_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_20 +if $data01 != null then + return -1 +endi +sql insert into st_bigint_21 using mt_bigint tags ("NULL") values (now, "NULL") +sql describe st_bigint_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_bigint_21 +if $data01 != null then + return -1 +endi +sql insert into st_bigint_22 using mt_bigint tags (9223372036854775807) values (now, 9223372036854775807) +sql describe st_bigint_22 +if $data23 != 9223372036854775807 then + return -1 +endi +sql select * from st_bigint_22 +if $data01 != 9223372036854775807 then + return -1 +endi +sql insert into st_bigint_23 using mt_bigint tags (-9223372036854775807) values (now, -9223372036854775807) +sql describe st_bigint_23 +if $data23 != -9223372036854775807 then + return -1 +endi +sql select * from st_bigint_23 +if $data01 != -9223372036854775807 then + return -1 +endi +sql insert into st_bigint_24 using mt_bigint tags (10) values (now, 10) +sql describe st_bigint_24 +if $data23 != 10 then + return -1 +endi +sql select * from st_bigint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_bigint_25 using mt_bigint tags ("-0") values (now, "-0") +sql describe st_bigint_25 +if $data23 != 0 then + return -1 +endi +sql select * from st_bigint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_bigint_26 using mt_bigint tags ('123') values (now, '123') +sql describe st_bigint_26 +if $data23 != 123 then + return -1 +endi +sql select * from st_bigint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_bigint_27 using mt_bigint tags (+056) values (now, +00056) +sql describe st_bigint_27 +if $data23 != 56 then + return -1 +endi +sql select * from st_bigint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_bigint_28 using mt_bigint tags (-056) values (now, -0056) +sql describe st_bigint_28 +if $data23 != -56 then + return -1 +endi +sql select * from st_bigint_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +sql alter table st_bigint_0 set tag tagname=9223372036854775807 +sql describe st_bigint_0 +if $data23 != 9223372036854775807 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname=-9223372036854775807 +sql describe st_bigint_0 +if $data23 != -9223372036854775807 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname=+100 +sql describe st_bigint_0 +if $data23 != 100 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname=-33 +sql describe st_bigint_0 +if $data23 != -33 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname='+98' +sql describe st_bigint_0 +if $data23 != 98 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname='-076' +sql describe st_bigint_0 +if $data23 != -76 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname=+0012 +sql describe st_bigint_0 +if $data23 != 12 then + return -1 +endi +sql alter table st_bigint_0 set tag tagname=-00063 +sql describe st_bigint_0 +if $data23 != -63 then + return -1 +endi + +## case 04: illegal input +################## when overflow, auto set max +sql create table st_bigint_e0 using mt_bigint tags (9223372036854775808) +sql_error create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808) +sql create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080) +sql_error create table st_bigint_e0_3 using mt_bigint tags (-9223372036854775809) +#sql_error create table st_bigint_e0 using mt_bigint tags (12.80) truncate integer part +#sql_error create table st_bigint_e0 using mt_bigint tags (-11.80) +sql_error create table st_bigint_e0 using mt_bigint tags (123abc) +sql_error create table st_bigint_e0 using mt_bigint tags ("123abc") +sql_error create table st_bigint_e0 using mt_bigint tags (abc) +sql_error create table st_bigint_e0 using mt_bigint tags ("abc") +sql_error create table st_bigint_e0 using mt_bigint tags (" ") +sql_error create table st_bigint_e0 using mt_bigint tags ('') + +sql create table st_bigint_e0 using mt_bigint tags (123) +sql create table st_bigint_e1 using mt_bigint tags (123) +sql create table st_bigint_e2 using mt_bigint tags (123) +sql create table st_bigint_e3 using mt_bigint tags (123) +sql create table st_bigint_e4 using mt_bigint tags (123) +sql create table st_bigint_e5 using mt_bigint tags (123) +sql create table st_bigint_e6 using mt_bigint tags (123) +sql create table st_bigint_e7 using mt_bigint tags (123) +sql create table st_bigint_e8 using mt_bigint tags (123) +sql create table st_bigint_e9 using mt_bigint tags (123) +sql create table st_bigint_e10 using mt_bigint tags (123) +sql create table st_bigint_e11 using mt_bigint tags (123) +sql create table st_bigint_e12 using mt_bigint tags (123) + +sql_error insert into st_bigint_e0 values (now, 9223372036854775808) +sql_error insert into st_bigint_e1 values (now, -9223372036854775808) +sql_error insert into st_bigint_e2 values (now, 9223372036854775809) +sql_error insert into st_bigint_e3 values (now, -9223372036854775808) +#sql_error insert into st_bigint_e4 values (now, 922337203.6854775808) +#sql_error insert into st_bigint_e5 values (now, -922337203685477580.9) +sql_error insert into st_bigint_e6 values (now, 123abc) +sql_error insert into st_bigint_e7 values (now, "123abc") +sql_error insert into st_bigint_e9 values (now, abc) +sql_error insert into st_bigint_e10 values (now, "abc") +sql_error insert into st_bigint_e11 values (now, " ") +sql_error insert into st_bigint_e12 values (now, '') + +sql_error insert into st_bigint_e13 using mt_bigint tags (033) values (now, 9223372036854775808) +sql_error insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808) +sql_error insert into st_bigint_e15 using mt_bigint tags (033) values (now, 9223372036854775818) +sql_error insert into st_bigint_e16 using mt_bigint tags (033) values (now, -9923372036854775808) +#sql_error insert into st_bigint_e17 using mt_bigint tags (033) values (now, 92233720368547758.08) +#sql_error insert into st_bigint_e18 using mt_bigint tags (033) values (now, -92233720368547.75808) +sql_error insert into st_bigint_e19 using mt_bigint tags (033) values (now, 123abc) +sql_error insert into st_bigint_e20 using mt_bigint tags (033) values (now, "123abc") +sql_error insert into st_bigint_e22 using mt_bigint tags (033) values (now, abc) +sql_error insert into st_bigint_e23 using mt_bigint tags (033) values (now, "abc") +sql_error insert into st_bigint_e24 using mt_bigint tags (033) values (now, " ") +sql_error insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') + +sql_error insert into st_bigint_e13_0 using mt_bigint tags (9223372036854775808) values (now, -033) +sql_error insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033) +sql_error insert into st_bigint_e15_0 using mt_bigint tags (9223372036854775809) values (now, -033) +sql_error insert into st_bigint_e16_0 using mt_bigint tags (-9223372036854775898) values (now, -033) +#sql_error insert into st_bigint_e17 using mt_bigint tags (12.80) values (now, -033) +#sql_error insert into st_bigint_e18 using mt_bigint tags (-11.80) values (now, -033) +sql_error insert into st_bigint_e19 using mt_bigint tags (123abc) values (now, -033) +sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now, -033) +sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033) +sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033) +sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033) +sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) + +sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e15 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e16 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e17 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e18 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e19 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e20 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e21 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e22 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e23 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e24 using mt_bigint tags (033) values (now, 00062) +sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, 00062) + +sql alter table st_bigint_e13 set tag tagname=9223372036854775808 +sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775808 +sql alter table st_bigint_e15 set tag tagname=92233720368547758080 +sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 +sql_error alter table st_bigint_e19 set tag tagname=123abc +sql_error alter table st_bigint_e20 set tag tagname="123abc" +sql_error alter table st_bigint_e22 set tag tagname=abc +sql_error alter table st_bigint_e23 set tag tagname="abc" +sql_error alter table st_bigint_e24 set tag tagname=" " +sql_error alter table st_bigint_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_bool.sim b/tests/script/general/parser/columnValue_bool.sim new file mode 100644 index 0000000000..2c896308fd --- /dev/null +++ b/tests/script/general/parser/columnValue_bool.sim @@ -0,0 +1,630 @@ +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: bool +print ========== bool +sql create table mt_bool (ts timestamp, c bool) tags (tagname bool) + +## case 00: static create table for test tag values +sql create table st_bool_0 using mt_bool tags (null) +sql describe st_bool_0 +if $data23 != NULL then + print ==1== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_1 using mt_bool tags (NULL) +sql describe st_bool_1 +if $data23 != NULL then + print ==2== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_2 using mt_bool tags ('null') +sql describe st_bool_2 +if $data23 != NULL then + print ==3== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_3 using mt_bool tags ('NULL') +sql describe st_bool_3 +if $data23 != NULL then + print ==4== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_4 using mt_bool tags ("null") +sql describe st_bool_4 +if $data23 != NULL then + print ==5== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_5 using mt_bool tags ("NULL") +sql describe st_bool_5 +if $data23 != NULL then + print ==6== expect: NULL, actually: $data23 + return -1 +endi +sql create table st_bool_6 using mt_bool tags ("true") +sql describe st_bool_6 +if $data23 != true then + print ==7== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_7 using mt_bool tags ('true') +sql describe st_bool_7 +if $data23 != true then + print ==8== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_8 using mt_bool tags (true) +sql describe st_bool_8 +if $data23 != true then + print ==9== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_9 using mt_bool tags ("false") +sql describe st_bool_9 +if $data23 != false then + print ==10== expect: false, actually: $data23 + return -1 +endi +sql create table st_bool_10 using mt_bool tags ('false') +sql describe st_bool_10 +if $data23 != false then + print ==11== expect: false, actually: $data23 + return -1 +endi +sql create table st_bool_11 using mt_bool tags (false) +sql describe st_bool_11 +if $data23 != false then + print ==12== expect: false, actually: $data23 + return -1 +endi +sql create table st_bool_12 using mt_bool tags (0) +sql describe st_bool_12 +if $data23 != false then + print ==13== expect: false, actually: $data23 + return -1 +endi +sql create table st_bool_13 using mt_bool tags (1) +sql describe st_bool_13 +if $data23 != true then + print ==14== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_14 using mt_bool tags (6.9) +sql describe st_bool_14 +if $data23 != true then + print ==15== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_15 using mt_bool tags (-3) +sql describe st_bool_15 +if $data23 != true then + print ==16== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_15_0 using mt_bool tags (+300) +sql describe st_bool_15_0 +if $data23 != true then + print ==16== expect: true, actually: $data23 + return -1 +endi +sql create table st_bool_15_1 using mt_bool tags (-8.03) +sql describe st_bool_15_1 +if $data23 != true then + print ==16== expect: true, actually: $data23 + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_bool_0 values (now, null) +sql select * from st_bool_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==17== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_1 values (now, NULL) +sql select * from st_bool_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==18== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_2 values (now, 'null') +sql select * from st_bool_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==19== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_3 values (now, 'NULL') +sql select * from st_bool_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==20== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_4 values (now, "null") +sql select * from st_bool_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==21== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_5 values (now, "NULL") +sql select * from st_bool_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + print ==22== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_6 values (now, "true") +sql select * from st_bool_6 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==23== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_7 values (now, 'true') +sql select * from st_bool_7 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==24== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_8 values (now, true) +sql select * from st_bool_8 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==25== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_9 values (now, "false") +sql select * from st_bool_9 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==26== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_10 values (now, 'false') +sql select * from st_bool_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==27== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_11 values (now, false) +sql select * from st_bool_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==28== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_12 values (now, 0) +sql select * from st_bool_12 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + print ==29== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_13 values (now, 1) +sql select * from st_bool_13 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==30== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_14 values (now, 6.9) +sql select * from st_bool_14 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==31== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_15 values (now, -3) +sql select * from st_bool_15 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_15_0 values (now, +300) +sql select * from st_bool_15_0 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_15_1 values (now, -3.15) +sql select * from st_bool_15_1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + print ==32== expect: true, actually: $data01 + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_bool_16 using mt_bool tags (null) values (now, null) +sql describe st_bool_16 +if $data23 != NULL then + print ==33== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_16 +if $data01 != null then + print ==34== expect: NULL, actually: $data01 + return -1 +endi + +sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL) +sql describe st_bool_17 +if $data23 != NULL then + print ==35== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_17 +if $data01 != null then + print ==36== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_18 using mt_bool tags ('null') values (now, 'null') +sql describe st_bool_18 +if $data23 != NULL then + print ==37== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_18 +if $data01 != null then + print ==38== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL') +sql describe st_bool_19 +if $data23 != NULL then + print ==39== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_19 +if $data01 != null then + print ==40== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_20 using mt_bool tags ("null") values (now, "null") +sql describe st_bool_20 +if $data23 != NULL then + print ==41== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_20 +if $data01 != null then + print ==42== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL") +sql describe st_bool_21 +if $data23 != NULL then + print ==43== expect: NULL, actually: $data23 + return -1 +endi +sql select * from st_bool_21 +if $data01 != null then + print ==44== expect: NULL, actually: $data01 + return -1 +endi +sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true") +sql describe st_bool_22 +if $data23 != true then + print ==45== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_22 +if $data01 != 1 then + print ==46== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true') +sql describe st_bool_23 +if $data23 != true then + print ==47== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_23 +if $data01 != 1 then + print ==48== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_24 using mt_bool tags (true) values (now, true) +sql describe st_bool_24 +if $data23 != true then + print ==49== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_24 +if $data01 != 1 then + print ==50== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false") +sql describe st_bool_25 +if $data23 != false then + print ==51== expect: false, actually: $data23 + return -1 +endi +sql select * from st_bool_25 +if $data01 != 0 then + print ==52== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false') +sql describe st_bool_26 +if $data23 != false then + print ==53== expect: false, actually: $data23 + return -1 +endi +sql select * from st_bool_26 +if $data01 != 0 then + print ==54== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_27 using mt_bool tags (false) values (now, false) +sql describe st_bool_27 +if $data23 != false then + print ==55== expect: false, actually: $data23 + return -1 +endi +sql select * from st_bool_27 +if $data01 != 0 then + print ==56== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_28 using mt_bool tags (0) values (now, 0) +sql describe st_bool_28 +if $data23 != false then + print ==57== expect: false, actually: $data23 + return -1 +endi +sql select * from st_bool_28 +if $data01 != 0 then + print ==58== expect: false, actually: $data01 + return -1 +endi +sql insert into st_bool_29 using mt_bool tags (1) values (now, 1) +sql describe st_bool_29 +if $data23 != true then + print ==59== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_29 +if $data01 != 1 then + print ==60== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9) +sql describe st_bool_30 +if $data23 != true then + print ==61== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_30 +if $data01 != 1 then + print ==62== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3) +sql describe st_bool_31 +if $data23 != true then + print ==63== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_31 +if $data01 != 1 then + print ==64== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300) +sql describe st_bool_32 +if $data23 != true then + print ==63== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_32 +if $data01 != 1 then + print ==64== expect: true, actually: $data01 + return -1 +endi +sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890) +sql describe st_bool_33 +if $data23 != true then + print ==63== expect: true, actually: $data23 + return -1 +endi +sql select * from st_bool_33 +if $data01 != 1 then + print ==64== expect: true, actually: $data01 + return -1 +endi + + + + + + +## case 03: alter tag values +sql alter table st_bool_0 set tag tagname=true +sql describe st_bool_0 +if $data23 != true then + return -1 +endi +sql alter table st_bool_0 set tag tagname=NULL +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname=false +sql describe st_bool_0 +if $data23 != false then + return -1 +endi +sql alter table st_bool_0 set tag tagname=null +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname='true' +sql describe st_bool_0 +if $data23 != true then + return -1 +endi +sql alter table st_bool_0 set tag tagname='null' +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname='false' +sql describe st_bool_0 +if $data23 != false then + return -1 +endi +sql alter table st_bool_0 set tag tagname='NULL' +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname="true" +sql describe st_bool_0 +if $data23 != true then + return -1 +endi +sql alter table st_bool_0 set tag tagname="null" +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname="false" +sql describe st_bool_0 +if $data23 != false then + return -1 +endi +sql alter table st_bool_0 set tag tagname="NULL" +sql describe st_bool_0 +if $data23 != NULL then + return -1 +endi +sql alter table st_bool_0 set tag tagname=1 +sql describe st_bool_0 +if $data23 != true then + return -1 +endi +sql alter table st_bool_0 set tag tagname=0 +sql describe st_bool_0 +if $data23 != false then + return -1 +endi +sql alter table st_bool_0 set tag tagname=6.9 +sql describe st_bool_0 +if $data23 != true then + return -1 +endi +sql alter table st_bool_0 set tag tagname=-3 +sql describe st_bool_0 +if $data23 != true then + return -1 +endi + +# case 04: illegal input +sql_error create table st_bool_e0 using mt_bool tags (123abc) +sql_error create table st_bool_e1 using mt_bool tags ("123abc") +sql_error create table st_bool_e2 using mt_bool tags ("123") +sql_error create table st_bool_e3 using mt_bool tags (abc) +sql_error create table st_bool_e4 using mt_bool tags ("abc") +sql_error create table st_bool_e5 using mt_bool tags (" ") +sql_error create table st_bool_e6 using mt_bool tags ('') + +sql create table st_bool_e0 using mt_bool tags (true) +sql create table st_bool_e1 using mt_bool tags (true) +sql create table st_bool_e2 using mt_bool tags (true) +sql create table st_bool_e3 using mt_bool tags (true) +sql create table st_bool_e4 using mt_bool tags (true) +sql create table st_bool_e5 using mt_bool tags (true) +sql create table st_bool_e6 using mt_bool tags (true) + +sql_error insert into st_bool_e0 values (now, 123abc) +sql_error insert into st_bool_e1 values (now, "123abc") +sql_error insert into st_bool_e2 values (now, "123") +sql_error insert into st_bool_e3 values (now, abc) +sql_error insert into st_bool_e4 values (now, "abc") +sql_error insert into st_bool_e5 values (now, " ") +sql_error insert into st_bool_e6 values (now, '') + +sql_error insert into st_bool_e10 using mt_bool tags (123abc) values (now, 1) +sql_error insert into st_bool_e11 using mt_bool tags ("123abc") values (now, 1) +sql_error insert into st_bool_e12 using mt_bool tags ("123") values (now, 1) +sql_error insert into st_bool_e13 using mt_bool tags (abc) values (now, 1) +sql_error insert into st_bool_e14 using mt_bool tags ("abc") values (now, 1) +sql_error insert into st_bool_e15 using mt_bool tags (" ") values (now, 1) +sql_error insert into st_bool_e16 using mt_bool tags ('') values (now, 1) + +sql_error insert into st_bool_e17 using mt_bool tags (1) values (now, 123abc) +sql_error insert into st_bool_e18 using mt_bool tags (1) values (now, "123abc") +sql_error insert into st_bool_e19 using mt_bool tags (1) values (now, "123") +sql_error insert into st_bool_e20 using mt_bool tags (1) values (now, abc) +sql_error insert into st_bool_e21 using mt_bool tags (1) values (now, "abc") +sql_error insert into st_bool_e22 using mt_bool tags (1) values (now, " ") +sql_error insert into st_bool_e23 using mt_bool tags (1) values (now, '') + +sql insert into st_bool_e10 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e11 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e12 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e13 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e14 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e15 using mt_bool tags (1) values (now, 1) +sql insert into st_bool_e16 using mt_bool tags (1) values (now, 1) + +sql_error alter table st_bool_e10 set tag tagname=123abc +sql_error alter table st_bool_e11 set tag tagname="123abc" +sql_error alter table st_bool_e12 set tag tagname="123" +sql_error alter table st_bool_e13 set tag tagname=abc +sql_error alter table st_bool_e14 set tag tagname="abc" +sql_error alter table st_bool_e15 set tag tagname=" " +sql_error alter table st_bool_e16 set tag tagname='' + diff --git a/tests/script/general/parser/columnValue_double.sim b/tests/script/general/parser/columnValue_double.sim new file mode 100644 index 0000000000..1c79ec4ff7 --- /dev/null +++ b/tests/script/general/parser/columnValue_double.sim @@ -0,0 +1,524 @@ +#### +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: double +print ========== double +sql create table mt_double (ts timestamp, c double) tags (tagname double) + +## case 00: static create table for test tag values +sql create table st_double_0 using mt_double tags (null) +sql describe st_double_0 +if $data23 != NULL then + return -1 +endi +sql create table st_double_1 using mt_double tags (NULL) +sql describe st_double_1 +if $data23 != NULL then + return -1 +endi +sql create table st_double_2 using mt_double tags ('null') +sql describe st_double_2 +if $data23 != NULL then + return -1 +endi +sql create table st_double_3 using mt_double tags ('NULL') +sql describe st_double_3 +if $data23 != NULL then + return -1 +endi +sql create table st_double_4 using mt_double tags ("null") +sql describe st_double_4 +if $data23 != NULL then + return -1 +endi +sql create table st_double_5 using mt_double tags ("NULL") +sql describe st_double_5 +if $data23 != NULL then + return -1 +endi +sql create table st_double_6 using mt_double tags (-123.321) +sql describe st_double_6 +if $data23 != -123.321000 then + return -1 +endi +sql create table st_double_7 using mt_double tags (+1.567) +sql describe st_double_7 +if $data23 != 1.567000 then + return -1 +endi +sql create table st_double_8 using mt_double tags (379.001) +sql describe st_double_8 +if $data23 != 379.001000 then + return -1 +endi +sql create table st_double_9 using mt_double tags (1.5e+3) +sql describe st_double_9 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_double_10 using mt_double tags (-1.5e-3) +sql describe st_double_10 +if $data23 != -0.001500 then + return -1 +endi +sql create table st_double_11 using mt_double tags (+1.5e+3) +sql describe st_double_11 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_double_12 using mt_double tags (-1.5e+3) +sql describe st_double_12 +if $data23 != -1500.000000 then + return -1 +endi +sql create table st_double_13 using mt_double tags (1.5e-3) +sql describe st_double_13 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_double_14 using mt_double tags (1.5E-3) +sql describe st_double_14 +if $data23 != 0.001500 then + return -1 +endi + +sql create table st_double_6_0 using mt_double tags ('-123.321') +sql describe st_double_6_0 +if $data23 != -123.321000 then + return -1 +endi +sql create table st_double_7_0 using mt_double tags ('+1.567') +sql describe st_double_7_0 +if $data23 != 1.567000 then + return -1 +endi +sql create table st_double_8_0 using mt_double tags ('379.001') +sql describe st_double_8_0 +if $data23 != 379.001000 then + return -1 +endi +sql create table st_double_9_0 using mt_double tags ('1.5e+3') +sql describe st_double_9_0 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_double_10_0 using mt_double tags ('-1.5e-3') +sql describe st_double_10_0 +if $data23 != -0.001500 then + return -1 +endi +sql create table st_double_11_0 using mt_double tags ('+1.5e+3') +sql describe st_double_11_0 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_double_12_0 using mt_double tags ('-1.5e+3') +sql describe st_double_12_0 +if $data23 != -1500.000000 then + return -1 +endi +sql create table st_double_13_0 using mt_double tags ('1.5e-3') +sql describe st_double_13_0 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_double_14_0 using mt_double tags ('1.5E-3') +sql describe st_double_14_0 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_double_15_0 using mt_double tags (1.7976931348623157e+308) +sql describe st_double_15_0 +#if $data23 != 0.001500 then +# return -1 +#endi +sql create table st_double_16_0 using mt_double tags (-1.7976931348623157e+308) +sql describe st_double_16_0 +#if $data23 != 0.001500 then +# return -1 +#endi + +## case 01: insert values for test column values +sql insert into st_double_0 values (now, null) +sql select * from st_double_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_double_1 values (now, NULL) +sql select * from st_double_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_double_2 values (now, 'null') +sql select * from st_double_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_double_3 values (now, 'NULL') +sql select * from st_double_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_double_4 values (now, "null") +sql select * from st_double_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_double_5 values (now, "NULL") +sql select * from st_double_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql insert into st_double_6 values (now, 1.7976931348623157e+308) +sql select * from st_double_6 +if $rows != 1 then + return -1 +endi +#if $data01 != 340282346638528859811704183484516925440.00000 then +# print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 +# return -1 +#endi +sql insert into st_double_7 values (now, -1.7976931348623157e+308) +sql select * from st_double_7 +if $rows != 1 then + return -1 +endi +#if $data01 != -340282346638528859811704183484516925440.00000 then +# return -1 +#endi +sql insert into st_double_8 values (now, +100.89) +sql select * from st_double_8 +if $rows != 1 then + return -1 +endi +#if $data01 != 100.89000 then +# return -1 +#endi +sql insert into st_double_9 values (now, "-0.98") +sql select * from st_double_9 +if $rows != 1 then + return -1 +endi +#if $data01 != -0.980000 then +# return -1 +#endi +sql insert into st_double_10 values (now, '0') +sql select * from st_double_10 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then # tsim only print 4 bits after dot +# return -1 +#endi +sql insert into st_double_11 values (now, -0) +sql select * from st_double_11 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then +# return -1 +#endi +sql insert into st_double_12 values (now, "+056") +sql select * from st_double_12 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_double_13 values (now, +056) +sql select * from st_double_13 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_double_14 values (now, -056) +sql select * from st_double_14 +if $rows != 1 then + return -1 +endi +#if $data01 != -56 then +# return -1 +#endi + +## case 02: dynamic create table for test tag values +sql insert into st_double_16 using mt_double tags (null) values (now, null) +sql describe st_double_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_16 +if $data01 != null then + return -1 +endi + +sql insert into st_double_17 using mt_double tags (NULL) values (now, NULL) +sql describe st_double_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_17 +if $data01 != null then + return -1 +endi +sql insert into st_double_18 using mt_double tags ('null') values (now, 'null') +sql describe st_double_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_18 +if $data01 != null then + return -1 +endi +sql insert into st_double_19 using mt_double tags ('NULL') values (now, 'NULL') +sql describe st_double_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_19 +if $data01 != null then + return -1 +endi +sql insert into st_double_20 using mt_double tags ("null") values (now, "null") +sql describe st_double_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_20 +if $data01 != null then + return -1 +endi +sql insert into st_double_21 using mt_double tags ("NULL") values (now, "NULL") +sql describe st_double_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_double_21 +if $data01 != null then + return -1 +endi +sql insert into st_double_22 using mt_double tags (127) values (now, 1.7976931348623157e+308) +sql describe st_double_22 +#if $data23 != 127 then +# return -1 +#endi +sql select * from st_double_22 +#if $data01 != 127 then +# return -1 +#endi +sql insert into st_double_23 using mt_double tags (-127) values (now, -1.7976931348623157e+308) +sql describe st_double_23 +#if $data23 != -127 then +# return -1 +#endi +sql select * from st_double_23 +#if $data01 != -127 then +# return -1 +#endi +sql insert into st_double_24 using mt_double tags (10) values (now, 10) +sql describe st_double_24 +#if $data23 != 10 then +# return -1 +#endi +sql select * from st_double_24 +#if $data01 != 10 then +# return -1 +#endi +sql insert into st_double_25 using mt_double tags ("-0") values (now, "-0") +sql describe st_double_25 +#if $data23 != 0 then +# return -1 +#endi +sql select * from st_double_25 +#if $data01 != 0 then +# return -1 +#endi +sql insert into st_double_26 using mt_double tags ('123') values (now, '12.3') +sql describe st_double_26 +#if $data23 != 123 then +# return -1 +#endi +sql select * from st_double_26 +#if $data01 != 123 then +# return -1 +#endi +sql insert into st_double_27 using mt_double tags (+056) values (now, +0005.6) +sql describe st_double_27 +#if $data23 != 56 then +# return -1 +#endi +sql select * from st_double_27 +#if $data01 != 56 then +# return -1 +#endi +sql insert into st_double_28 using mt_double tags (-056) values (now, -005.6) +sql describe st_double_28 +#if $data23 != -56 then +# return -1 +#endi +sql select * from st_double_28 +#if $data01 != -56 then +# return -1 +#endi + +## case 03: alter tag values +sql alter table st_double_0 set tag tagname=1.7976931348623157e+308 +sql describe st_double_0 +#if $data23 != 127 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname=-1.7976931348623157e+308 +sql describe st_double_0 +#if $data23 != -127 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname=+10.340 +sql describe st_double_0 +#if $data23 != 100 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname=-33.87 +sql describe st_double_0 +#if $data23 != -33 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname='+9.8' +sql describe st_double_0 +#if $data23 != 98 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname='-07.6' +sql describe st_double_0 +#if $data23 != -76 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname=+0012.871 +sql describe st_double_0 +#if $data23 != 12 then +# return -1 +#endi +sql alter table st_double_0 set tag tagname=-00063.582 +sql describe st_double_0 +#if $data23 != -63 then +# return -1 +#endi + +## case 04: illegal input +sql_error create table st_double_e0 using mt_double tags (1.8976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (-1.8976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (31.7976931348623157e+308) +sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+308) +#sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part +#sql_error create table st_double_e0 using mt_double tags (-11.80) +sql_error create table st_double_e0 using mt_double tags (123abc) +sql_error create table st_double_e0 using mt_double tags ("123abc") +sql_error create table st_double_e0 using mt_double tags (abc) +sql_error create table st_double_e0 using mt_double tags ("abc") +sql_error create table st_double_e0 using mt_double tags (" ") +sql_error create table st_double_e0 using mt_double tags ('') + +sql create table st_double_e0 using mt_double tags (123) +sql create table st_double_e1 using mt_double tags (123) +sql create table st_double_e2 using mt_double tags (123) +sql create table st_double_e3 using mt_double tags (123) +sql create table st_double_e4 using mt_double tags (123) +sql create table st_double_e5 using mt_double tags (123) +sql create table st_double_e6 using mt_double tags (123) +sql create table st_double_e7 using mt_double tags (123) +sql create table st_double_e8 using mt_double tags (123) +sql create table st_double_e9 using mt_double tags (123) +sql create table st_double_e10 using mt_double tags (123) +sql create table st_double_e11 using mt_double tags (123) +sql create table st_double_e12 using mt_double tags (123) + +sql_error insert into st_double_e0 values (now, 11.7976931348623157e+308) +sql_error insert into st_double_e1 values (now, -11.7976931348623157e+308) +sql_error insert into st_double_e2 values (now, 111.7976931348623157e+308) +sql_error insert into st_double_e3 values (now, -111.7976931348623157e+308) +#sql_error insert into st_double_e4 values (now, 12.80) +#sql_error insert into st_double_e5 values (now, -11.80) +sql_error insert into st_double_e6 values (now, 123abc) +sql_error insert into st_double_e7 values (now, "123abc") +sql_error insert into st_double_e9 values (now, abc) +sql_error insert into st_double_e10 values (now, "abc") +sql_error insert into st_double_e11 values (now, " ") +sql_error insert into st_double_e12 values (now, '') + +sql_error insert into st_double_e13 using mt_double tags (033) values (now, 11.7976931348623157e+308) +sql_error insert into st_double_e14 using mt_double tags (033) values (now, -11.7976931348623157e+308) +sql_error insert into st_double_e15 using mt_double tags (033) values (now, 131.7976931348623157e+308) +sql_error insert into st_double_e16 using mt_double tags (033) values (now, -131.7976931348623157e+308) +#sql_error insert into st_double_e17 using mt_double tags (033) values (now, 12.80) +#sql_error insert into st_double_e18 using mt_double tags (033) values (now, -11.80) +sql_error insert into st_double_e19 using mt_double tags (033) values (now, 123abc) +sql_error insert into st_double_e20 using mt_double tags (033) values (now, "123abc") +sql_error insert into st_double_e22 using mt_double tags (033) values (now, abc) +sql_error insert into st_double_e23 using mt_double tags (033) values (now, "abc") +sql_error insert into st_double_e24 using mt_double tags (033) values (now, " ") +sql_error insert into st_double_e25 using mt_double tags (033) values (now, '') + +sql_error insert into st_double_e13 using mt_double tags (31.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e14 using mt_double tags (-31.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e15 using mt_double tags (131.7976931348623157e+308) values (now, -033) +sql_error insert into st_double_e16 using mt_double tags (-131.7976931348623157e+308) values (now, -033) +#sql_error insert into st_double_e17 using mt_double tags (12.80) values (now, -033) +#sql_error insert into st_double_e18 using mt_double tags (-11.80) values (now, -033) +sql_error insert into st_double_e19 using mt_double tags (123abc) values (now, -033) +sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now, -033) +sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033) +sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033) +sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033) +sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033) + +sql insert into st_double_e13 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e14 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e15 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e16 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e17 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e18 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e19 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e20 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e21 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e22 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e23 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e24 using mt_double tags (033) values (now, 00062) +sql insert into st_double_e25 using mt_double tags (033) values (now, 00062) + +sql_error alter table st_double_e13 set tag tagname=1.8976931348623157e+308 +sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308 +sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308 +sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308 +sql_error alter table st_double_e19 set tag tagname=123abc +sql_error alter table st_double_e20 set tag tagname="123abc" +sql_error alter table st_double_e22 set tag tagname=abc +sql_error alter table st_double_e23 set tag tagname="abc" +sql_error alter table st_double_e24 set tag tagname=" " +sql_error alter table st_double_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_float.sim b/tests/script/general/parser/columnValue_float.sim new file mode 100644 index 0000000000..58e413a50f --- /dev/null +++ b/tests/script/general/parser/columnValue_float.sim @@ -0,0 +1,524 @@ +#### +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: float +print ========== float +sql create table mt_float (ts timestamp, c float) tags (tagname float) + +## case 00: static create table for test tag values +sql create table st_float_0 using mt_float tags (null) +sql describe st_float_0 +if $data23 != NULL then + return -1 +endi +sql create table st_float_1 using mt_float tags (NULL) +sql describe st_float_1 +if $data23 != NULL then + return -1 +endi +sql create table st_float_2 using mt_float tags ('null') +sql describe st_float_2 +if $data23 != NULL then + return -1 +endi +sql create table st_float_3 using mt_float tags ('NULL') +sql describe st_float_3 +if $data23 != NULL then + return -1 +endi +sql create table st_float_4 using mt_float tags ("null") +sql describe st_float_4 +if $data23 != NULL then + return -1 +endi +sql create table st_float_5 using mt_float tags ("NULL") +sql describe st_float_5 +if $data23 != NULL then + return -1 +endi +sql create table st_float_6 using mt_float tags (-123.321) +sql describe st_float_6 +if $data23 != -123.320999 then + return -1 +endi +sql create table st_float_7 using mt_float tags (+1.567) +sql describe st_float_7 +if $data23 != 1.567000 then + return -1 +endi +sql create table st_float_8 using mt_float tags (379.001) +sql describe st_float_8 +if $data23 != 379.001007 then + return -1 +endi +sql create table st_float_9 using mt_float tags (1.5e+3) +sql describe st_float_9 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_float_10 using mt_float tags (-1.5e-3) +sql describe st_float_10 +if $data23 != -0.001500 then + return -1 +endi +sql create table st_float_11 using mt_float tags (+1.5e+3) +sql describe st_float_11 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_float_12 using mt_float tags (-1.5e+3) +sql describe st_float_12 +if $data23 != -1500.000000 then + return -1 +endi +sql create table st_float_13 using mt_float tags (1.5e-3) +sql describe st_float_13 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_float_14 using mt_float tags (1.5E-3) +sql describe st_float_14 +if $data23 != 0.001500 then + return -1 +endi + +sql create table st_float_6_0 using mt_float tags ('-123.321') +sql describe st_float_6_0 +if $data23 != -123.320999 then + return -1 +endi +sql create table st_float_7_0 using mt_float tags ('+1.567') +sql describe st_float_7_0 +if $data23 != 1.567000 then + return -1 +endi +sql create table st_float_8_0 using mt_float tags ('379.001') +sql describe st_float_8_0 +if $data23 != 379.001007 then + return -1 +endi +sql create table st_float_9_0 using mt_float tags ('1.5e+3') +sql describe st_float_9_0 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_float_10_0 using mt_float tags ('-1.5e-3') +sql describe st_float_10_0 +if $data23 != -0.001500 then + return -1 +endi +sql create table st_float_11_0 using mt_float tags ('+1.5e+3') +sql describe st_float_11_0 +if $data23 != 1500.000000 then + return -1 +endi +sql create table st_float_12_0 using mt_float tags ('-1.5e+3') +sql describe st_float_12_0 +if $data23 != -1500.000000 then + return -1 +endi +sql create table st_float_13_0 using mt_float tags ('1.5e-3') +sql describe st_float_13_0 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_float_14_0 using mt_float tags ('1.5E-3') +sql describe st_float_14_0 +if $data23 != 0.001500 then + return -1 +endi +sql create table st_float_15_0 using mt_float tags (3.40282347e+38) +sql describe st_float_15_0 +#if $data23 != 0.001500 then +# return -1 +#endi +sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) +sql describe st_float_16_0 +#if $data23 != 0.001500 then +# return -1 +#endi + +## case 01: insert values for test column values +sql insert into st_float_0 values (now, null) +sql select * from st_float_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_float_1 values (now, NULL) +sql select * from st_float_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_float_2 values (now, 'null') +sql select * from st_float_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_float_3 values (now, 'NULL') +sql select * from st_float_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_float_4 values (now, "null") +sql select * from st_float_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_float_5 values (now, "NULL") +sql select * from st_float_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +sql insert into st_float_6 values (now, 3.40282347e+38) +sql select * from st_float_6 +if $rows != 1 then + return -1 +endi +#if $data01 != 340282346638528859811704183484516925440.00000 then +# print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 +# return -1 +#endi +sql insert into st_float_7 values (now, -3.40282347e+38) +sql select * from st_float_7 +if $rows != 1 then + return -1 +endi +#if $data01 != -340282346638528859811704183484516925440.00000 then +# return -1 +#endi +sql insert into st_float_8 values (now, +100.89) +sql select * from st_float_8 +if $rows != 1 then + return -1 +endi +#if $data01 != 100.89000 then +# return -1 +#endi +sql insert into st_float_9 values (now, "-0.98") +sql select * from st_float_9 +if $rows != 1 then + return -1 +endi +#if $data01 != -0.980000 then +# return -1 +#endi +sql insert into st_float_10 values (now, '0') +sql select * from st_float_10 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then # tsim only print 4 bits after dot +# return -1 +#endi +sql insert into st_float_11 values (now, -0) +sql select * from st_float_11 +if $rows != 1 then + return -1 +endi +#if $data01 != 0.00000 then +# return -1 +#endi +sql insert into st_float_12 values (now, "+056") +sql select * from st_float_12 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_float_13 values (now, +056) +sql select * from st_float_13 +if $rows != 1 then + return -1 +endi +#if $data01 != 56.000000 then +# return -1 +#endi + +sql insert into st_float_14 values (now, -056) +sql select * from st_float_14 +if $rows != 1 then + return -1 +endi +#if $data01 != -56 then +# return -1 +#endi + +## case 02: dynamic create table for test tag values +sql insert into st_float_16 using mt_float tags (null) values (now, null) +sql describe st_float_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_16 +if $data01 != null then + return -1 +endi + +sql insert into st_float_17 using mt_float tags (NULL) values (now, NULL) +sql describe st_float_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_17 +if $data01 != null then + return -1 +endi +sql insert into st_float_18 using mt_float tags ('null') values (now, 'null') +sql describe st_float_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_18 +if $data01 != null then + return -1 +endi +sql insert into st_float_19 using mt_float tags ('NULL') values (now, 'NULL') +sql describe st_float_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_19 +if $data01 != null then + return -1 +endi +sql insert into st_float_20 using mt_float tags ("null") values (now, "null") +sql describe st_float_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_20 +if $data01 != null then + return -1 +endi +sql insert into st_float_21 using mt_float tags ("NULL") values (now, "NULL") +sql describe st_float_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_float_21 +if $data01 != null then + return -1 +endi +sql insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38) +sql describe st_float_22 +#if $data23 != 127 then +# return -1 +#endi +sql select * from st_float_22 +#if $data01 != 127 then +# return -1 +#endi +sql insert into st_float_23 using mt_float tags (-127) values (now, -3.40282347e+38) +sql describe st_float_23 +#if $data23 != -127 then +# return -1 +#endi +sql select * from st_float_23 +#if $data01 != -127 then +# return -1 +#endi +sql insert into st_float_24 using mt_float tags (10) values (now, 10) +sql describe st_float_24 +#if $data23 != 10 then +# return -1 +#endi +sql select * from st_float_24 +#if $data01 != 10 then +# return -1 +#endi +sql insert into st_float_25 using mt_float tags ("-0") values (now, "-0") +sql describe st_float_25 +#if $data23 != 0 then +# return -1 +#endi +sql select * from st_float_25 +#if $data01 != 0 then +# return -1 +#endi +sql insert into st_float_26 using mt_float tags ('123') values (now, '12.3') +sql describe st_float_26 +#if $data23 != 123 then +# return -1 +#endi +sql select * from st_float_26 +#if $data01 != 123 then +# return -1 +#endi +sql insert into st_float_27 using mt_float tags (+056) values (now, +0005.6) +sql describe st_float_27 +#if $data23 != 56 then +# return -1 +#endi +sql select * from st_float_27 +#if $data01 != 56 then +# return -1 +#endi +sql insert into st_float_28 using mt_float tags (-056) values (now, -005.6) +sql describe st_float_28 +#if $data23 != -56 then +# return -1 +#endi +sql select * from st_float_28 +#if $data01 != -56 then +# return -1 +#endi + +## case 03: alter tag values +sql alter table st_float_0 set tag tagname=3.40282347e+38 +sql describe st_float_0 +#if $data23 != 127 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname=-3.40282347e+38 +sql describe st_float_0 +#if $data23 != -127 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname=+10.340 +sql describe st_float_0 +#if $data23 != 100 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname=-33.87 +sql describe st_float_0 +#if $data23 != -33 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname='+9.8' +sql describe st_float_0 +#if $data23 != 98 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname='-07.6' +sql describe st_float_0 +#if $data23 != -76 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname=+0012.871 +sql describe st_float_0 +#if $data23 != 12 then +# return -1 +#endi +sql alter table st_float_0 set tag tagname=-00063.582 +sql describe st_float_0 +#if $data23 != -63 then +# return -1 +#endi + +## case 04: illegal input +sql_error create table st_float_e0 using mt_float tags (3.50282347e+38) +sql_error create table st_float_e0 using mt_float tags (-3.50282347e+38) +sql_error create table st_float_e0 using mt_float tags (333.40282347e+38) +sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38) +#sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part +#sql_error create table st_float_e0 using mt_float tags (-11.80) +sql_error create table st_float_e0 using mt_float tags (123abc) +sql_error create table st_float_e0 using mt_float tags ("123abc") +sql_error create table st_float_e0 using mt_float tags (abc) +sql_error create table st_float_e0 using mt_float tags ("abc") +sql_error create table st_float_e0 using mt_float tags (" ") +sql_error create table st_float_e0 using mt_float tags ('') + +sql create table st_float_e0 using mt_float tags (123) +sql create table st_float_e1 using mt_float tags (123) +sql create table st_float_e2 using mt_float tags (123) +sql create table st_float_e3 using mt_float tags (123) +sql create table st_float_e4 using mt_float tags (123) +sql create table st_float_e5 using mt_float tags (123) +sql create table st_float_e6 using mt_float tags (123) +sql create table st_float_e7 using mt_float tags (123) +sql create table st_float_e8 using mt_float tags (123) +sql create table st_float_e9 using mt_float tags (123) +sql create table st_float_e10 using mt_float tags (123) +sql create table st_float_e11 using mt_float tags (123) +sql create table st_float_e12 using mt_float tags (123) + +sql_error insert into st_float_e0 values (now, 3.50282347e+38) +sql_error insert into st_float_e1 values (now, -3.50282347e+38) +sql_error insert into st_float_e2 values (now, 13.40282347e+38) +sql_error insert into st_float_e3 values (now, -13.40282347e+38) +#sql_error insert into st_float_e4 values (now, 12.80) +#sql_error insert into st_float_e5 values (now, -11.80) +sql_error insert into st_float_e6 values (now, 123abc) +sql_error insert into st_float_e7 values (now, "123abc") +sql_error insert into st_float_e9 values (now, abc) +sql_error insert into st_float_e10 values (now, "abc") +sql_error insert into st_float_e11 values (now, " ") +sql_error insert into st_float_e12 values (now, '') + +sql_error insert into st_float_e13 using mt_float tags (033) values (now, 3.50282347e+38) +sql_error insert into st_float_e14 using mt_float tags (033) values (now, -3.50282347e+38) +sql_error insert into st_float_e15 using mt_float tags (033) values (now, 13.40282347e+38) +sql_error insert into st_float_e16 using mt_float tags (033) values (now, -13.40282347e+38) +#sql_error insert into st_float_e17 using mt_float tags (033) values (now, 12.80) +#sql_error insert into st_float_e18 using mt_float tags (033) values (now, -11.80) +sql_error insert into st_float_e19 using mt_float tags (033) values (now, 123abc) +sql_error insert into st_float_e20 using mt_float tags (033) values (now, "123abc") +sql_error insert into st_float_e22 using mt_float tags (033) values (now, abc) +sql_error insert into st_float_e23 using mt_float tags (033) values (now, "abc") +sql_error insert into st_float_e24 using mt_float tags (033) values (now, " ") +sql_error insert into st_float_e25 using mt_float tags (033) values (now, '') + +sql_error insert into st_float_e13 using mt_float tags (3.50282347e+38) values (now, -033) +sql_error insert into st_float_e14 using mt_float tags (-3.50282347e+38) values (now, -033) +sql_error insert into st_float_e15 using mt_float tags (13.40282347e+38) values (now, -033) +sql_error insert into st_float_e16 using mt_float tags (-13.40282347e+38) values (now, -033) +#sql_error insert into st_float_e17 using mt_float tags (12.80) values (now, -033) +#sql_error insert into st_float_e18 using mt_float tags (-11.80) values (now, -033) +sql_error insert into st_float_e19 using mt_float tags (123abc) values (now, -033) +sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, -033) +sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033) +sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033) +sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033) +sql_error insert into st_float_e25 using mt_float tags ('') values (now, -033) + +sql insert into st_float_e13 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e14 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e15 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e16 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e17 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e18 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e19 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e20 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e21 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e22 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e23 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e24 using mt_float tags (033) values (now, 00062) +sql insert into st_float_e25 using mt_float tags (033) values (now, 00062) + +sql_error alter table st_float_e13 set tag tagname=3.50282347e+38 +sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38 +sql_error alter table st_float_e15 set tag tagname=13.40282347e+38 +sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38 +sql_error alter table st_float_e19 set tag tagname=123abc +sql_error alter table st_float_e20 set tag tagname="123abc" +sql_error alter table st_float_e22 set tag tagname=abc +sql_error alter table st_float_e23 set tag tagname="abc" +sql_error alter table st_float_e24 set tag tagname=" " +sql_error alter table st_float_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_int.sim b/tests/script/general/parser/columnValue_int.sim new file mode 100644 index 0000000000..da3df4969b --- /dev/null +++ b/tests/script/general/parser/columnValue_int.sim @@ -0,0 +1,465 @@ +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: int +print ========== int +sql create table mt_int (ts timestamp, c int) tags (tagname int) + +## case 00: static create table for test tag values +sql create table st_int_0 using mt_int tags (null) +sql describe st_int_0 +if $data23 != NULL then + return -1 +endi +sql create table st_int_1 using mt_int tags (NULL) +sql describe st_int_1 +if $data23 != NULL then + return -1 +endi +sql create table st_int_2 using mt_int tags ('null') +sql describe st_int_2 +if $data23 != NULL then + return -1 +endi +sql create table st_int_3 using mt_int tags ('NULL') +sql describe st_int_3 +if $data23 != NULL then + return -1 +endi +sql create table st_int_4 using mt_int tags ("null") +sql describe st_int_4 +if $data23 != NULL then + return -1 +endi +sql create table st_int_5 using mt_int tags ("NULL") +sql describe st_int_5 +if $data23 != NULL then + return -1 +endi +sql create table st_int_6 using mt_int tags (-2147483647) +sql describe st_int_6 +if $data23 != -2147483647 then + return -1 +endi +sql create table st_int_7 using mt_int tags (2147483647) +sql describe st_int_7 +if $data23 != 2147483647 then + return -1 +endi +sql create table st_int_8 using mt_int tags (37) +sql describe st_int_8 +if $data23 != 37 then + return -1 +endi +sql create table st_int_9 using mt_int tags (-100) +sql describe st_int_9 +if $data23 != -100 then + return -1 +endi +sql create table st_int_10 using mt_int tags (+113) +sql describe st_int_10 +if $data23 != 113 then + return -1 +endi +sql create table st_int_11 using mt_int tags ('-100') +sql describe st_int_11 +if $data23 != -100 then + return -1 +endi +sql create table st_int_12 using mt_int tags ("+78") +sql describe st_int_12 +if $data23 != 78 then + return -1 +endi +sql create table st_int_13 using mt_int tags (+0078) +sql describe st_int_13 +if $data23 != 78 then + return -1 +endi +sql create table st_int_14 using mt_int tags (-00078) +sql describe st_int_14 +if $data23 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_int_0 values (now, null) +sql select * from st_int_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_1 values (now, NULL) +sql select * from st_int_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_2 values (now, 'null') +sql select * from st_int_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_3 values (now, 'NULL') +sql select * from st_int_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_4 values (now, "null") +sql select * from st_int_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_5 values (now, "NULL") +sql select * from st_int_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_int_6 values (now, 2147483647) +sql select * from st_int_6 +if $rows != 1 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_int_7 values (now, -2147483647) +sql select * from st_int_7 +if $rows != 1 then + return -1 +endi +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_int_8 values (now, +100) +sql select * from st_int_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_int_9 values (now, "-098") +sql select * from st_int_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_int_10 values (now, '0') +sql select * from st_int_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_int_11 values (now, -0) +sql select * from st_int_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_int_12 values (now, "+056") +sql select * from st_int_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_int_13 values (now, +056) +sql select * from st_int_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_int_14 values (now, -056) +sql select * from st_int_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_int_16 using mt_int tags (null) values (now, null) +sql describe st_int_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_16 +if $data01 != null then + return -1 +endi + +sql insert into st_int_17 using mt_int tags (NULL) values (now, NULL) +sql describe st_int_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_17 +if $data01 != null then + return -1 +endi +sql insert into st_int_18 using mt_int tags ('null') values (now, 'null') +sql describe st_int_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_18 +if $data01 != null then + return -1 +endi +sql insert into st_int_19 using mt_int tags ('NULL') values (now, 'NULL') +sql describe st_int_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_19 +if $data01 != null then + return -1 +endi +sql insert into st_int_20 using mt_int tags ("null") values (now, "null") +sql describe st_int_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_20 +if $data01 != null then + return -1 +endi +sql insert into st_int_21 using mt_int tags ("NULL") values (now, "NULL") +sql describe st_int_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_int_21 +if $data01 != null then + return -1 +endi +sql insert into st_int_22 using mt_int tags (2147483647) values (now, 2147483647) +sql describe st_int_22 +if $data23 != 2147483647 then + return -1 +endi +sql select * from st_int_22 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_int_23 using mt_int tags (-2147483647) values (now, -2147483647) +sql describe st_int_23 +if $data23 != -2147483647 then + return -1 +endi +sql select * from st_int_23 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_int_24 using mt_int tags (10) values (now, 10) +sql describe st_int_24 +if $data23 != 10 then + return -1 +endi +sql select * from st_int_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_int_25 using mt_int tags ("-0") values (now, "-0") +sql describe st_int_25 +if $data23 != 0 then + return -1 +endi +sql select * from st_int_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_26 using mt_int tags ('123') values (now, '123') +sql describe st_int_26 +if $data23 != 123 then + return -1 +endi +sql select * from st_int_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_int_27 using mt_int tags (+056) values (now, +00056) +sql describe st_int_27 +if $data23 != 56 then + return -1 +endi +sql select * from st_int_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_int_28 using mt_int tags (-056) values (now, -0056) +sql describe st_int_28 +if $data23 != -56 then + return -1 +endi +sql select * from st_int_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +sql alter table st_int_0 set tag tagname=2147483647 +sql describe st_int_0 +if $data23 != 2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-2147483647 +sql describe st_int_0 +if $data23 != -2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+100 +sql describe st_int_0 +if $data23 != 100 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-33 +sql describe st_int_0 +if $data23 != -33 then + return -1 +endi +sql alter table st_int_0 set tag tagname='+98' +sql describe st_int_0 +if $data23 != 98 then + return -1 +endi +sql alter table st_int_0 set tag tagname='-076' +sql describe st_int_0 +if $data23 != -76 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+0012 +sql describe st_int_0 +if $data23 != 12 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-00063 +sql describe st_int_0 +if $data23 != -63 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_int_e0 using mt_int tags (2147483648) +sql_error create table st_int_e0 using mt_int tags (-2147483648) +sql_error create table st_int_e0 using mt_int tags (214748364800) +sql_error create table st_int_e0 using mt_int tags (-214748364800) +#sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part +#sql_error create table st_int_e0 using mt_int tags (-11.80) +sql_error create table st_int_e0 using mt_int tags (123abc) +sql_error create table st_int_e0 using mt_int tags ("123abc") +sql_error create table st_int_e0 using mt_int tags (abc) +sql_error create table st_int_e0 using mt_int tags ("abc") +sql_error create table st_int_e0 using mt_int tags (" ") +sql_error create table st_int_e0 using mt_int tags ('') + +sql create table st_int_e0 using mt_int tags (123) +sql create table st_int_e1 using mt_int tags (123) +sql create table st_int_e2 using mt_int tags (123) +sql create table st_int_e3 using mt_int tags (123) +sql create table st_int_e4 using mt_int tags (123) +sql create table st_int_e5 using mt_int tags (123) +sql create table st_int_e6 using mt_int tags (123) +sql create table st_int_e7 using mt_int tags (123) +sql create table st_int_e8 using mt_int tags (123) +sql create table st_int_e9 using mt_int tags (123) +sql create table st_int_e10 using mt_int tags (123) +sql create table st_int_e11 using mt_int tags (123) +sql create table st_int_e12 using mt_int tags (123) + +sql_error insert into st_int_e0 values (now, 2147483648) +sql_error insert into st_int_e1 values (now, -2147483648) +sql_error insert into st_int_e2 values (now, 3147483648) +sql_error insert into st_int_e3 values (now, -21474836481) +#sql_error insert into st_int_e4 values (now, 12.80) +#sql_error insert into st_int_e5 values (now, -11.80) +sql_error insert into st_int_e6 values (now, 123abc) +sql_error insert into st_int_e7 values (now, "123abc") +sql_error insert into st_int_e9 values (now, abc) +sql_error insert into st_int_e10 values (now, "abc") +sql_error insert into st_int_e11 values (now, " ") +sql_error insert into st_int_e12 values (now, '') + +sql_error insert into st_int_e13 using mt_int tags (033) values (now, 2147483648) +sql_error insert into st_int_e14 using mt_int tags (033) values (now, -2147483648) +sql_error insert into st_int_e15 using mt_int tags (033) values (now, 5147483648) +sql_error insert into st_int_e16 using mt_int tags (033) values (now, -21474836481) +#sql_error insert into st_int_e17 using mt_int tags (033) values (now, 12.80) +#sql_error insert into st_int_e18 using mt_int tags (033) values (now, -11.80) +sql_error insert into st_int_e19 using mt_int tags (033) values (now, 123abc) +sql_error insert into st_int_e20 using mt_int tags (033) values (now, "123abc") +sql_error insert into st_int_e22 using mt_int tags (033) values (now, abc) +sql_error insert into st_int_e23 using mt_int tags (033) values (now, "abc") +sql_error insert into st_int_e24 using mt_int tags (033) values (now, " ") +sql_error insert into st_int_e25 using mt_int tags (033) values (now, '') + +sql_error insert into st_int_e13 using mt_int tags (2147483648) values (now, -033) +sql_error insert into st_int_e14 using mt_int tags (-2147483648) values (now, -033) +sql_error insert into st_int_e15 using mt_int tags (21474836480) values (now, -033) +sql_error insert into st_int_e16 using mt_int tags (-2147483649) values (now, -033) +#sql_error insert into st_int_e17 using mt_int tags (12.80) values (now, -033) +#sql_error insert into st_int_e18 using mt_int tags (-11.80) values (now, -033) +sql_error insert into st_int_e19 using mt_int tags (123abc) values (now, -033) +sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033) +sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033) +sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033) +sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033) +sql_error insert into st_int_e25 using mt_int tags ('') values (now, -033) + +sql insert into st_int_e13 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e14 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e15 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e16 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e17 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e18 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e19 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e20 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e21 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e22 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e23 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e24 using mt_int tags (033) values (now, 00062) +sql insert into st_int_e25 using mt_int tags (033) values (now, 00062) + +sql_error alter table st_int_e13 set tag tagname=2147483648 +sql_error alter table st_int_e14 set tag tagname=-2147483648 +sql_error alter table st_int_e15 set tag tagname=12147483648 +sql_error alter table st_int_e16 set tag tagname=-3147483648 +sql_error alter table st_int_e19 set tag tagname=123abc +sql_error alter table st_int_e20 set tag tagname="123abc" +sql_error alter table st_int_e22 set tag tagname=abc +sql_error alter table st_int_e23 set tag tagname="abc" +sql_error alter table st_int_e24 set tag tagname=" " +sql_error alter table st_int_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_smallint.sim b/tests/script/general/parser/columnValue_smallint.sim new file mode 100644 index 0000000000..bf41087d61 --- /dev/null +++ b/tests/script/general/parser/columnValue_smallint.sim @@ -0,0 +1,465 @@ +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: smallint +print ========== smallint +sql create table mt_smallint (ts timestamp, c smallint) tags (tagname smallint) + +## case 00: static create table for test tag values +sql create table st_smallint_0 using mt_smallint tags (null) +sql describe st_smallint_0 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_1 using mt_smallint tags (NULL) +sql describe st_smallint_1 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_2 using mt_smallint tags ('null') +sql describe st_smallint_2 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_3 using mt_smallint tags ('NULL') +sql describe st_smallint_3 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_4 using mt_smallint tags ("null") +sql describe st_smallint_4 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_5 using mt_smallint tags ("NULL") +sql describe st_smallint_5 +if $data23 != NULL then + return -1 +endi +sql create table st_smallint_6 using mt_smallint tags (-32767) +sql describe st_smallint_6 +if $data23 != -32767 then + return -1 +endi +sql create table st_smallint_7 using mt_smallint tags (32767) +sql describe st_smallint_7 +if $data23 != 32767 then + return -1 +endi +sql create table st_smallint_8 using mt_smallint tags (37) +sql describe st_smallint_8 +if $data23 != 37 then + return -1 +endi +sql create table st_smallint_9 using mt_smallint tags (-100) +sql describe st_smallint_9 +if $data23 != -100 then + return -1 +endi +sql create table st_smallint_10 using mt_smallint tags (+113) +sql describe st_smallint_10 +if $data23 != 113 then + return -1 +endi +sql create table st_smallint_11 using mt_smallint tags ('-100') +sql describe st_smallint_11 +if $data23 != -100 then + return -1 +endi +sql create table st_smallint_12 using mt_smallint tags ("+78") +sql describe st_smallint_12 +if $data23 != 78 then + return -1 +endi +sql create table st_smallint_13 using mt_smallint tags (+0078) +sql describe st_smallint_13 +if $data23 != 78 then + return -1 +endi +sql create table st_smallint_14 using mt_smallint tags (-00078) +sql describe st_smallint_14 +if $data23 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_smallint_0 values (now, null) +sql select * from st_smallint_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_1 values (now, NULL) +sql select * from st_smallint_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_2 values (now, 'null') +sql select * from st_smallint_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_3 values (now, 'NULL') +sql select * from st_smallint_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_4 values (now, "null") +sql select * from st_smallint_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_5 values (now, "NULL") +sql select * from st_smallint_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_smallint_6 values (now, 32767) +sql select * from st_smallint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 32767 then + return -1 +endi +sql insert into st_smallint_7 values (now, -32767) +sql select * from st_smallint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -32767 then + return -1 +endi +sql insert into st_smallint_8 values (now, +100) +sql select * from st_smallint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_smallint_9 values (now, "-098") +sql select * from st_smallint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_smallint_10 values (now, '0') +sql select * from st_smallint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_11 values (now, -0) +sql select * from st_smallint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_12 values (now, "+056") +sql select * from st_smallint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_smallint_13 values (now, +056) +sql select * from st_smallint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_smallint_14 values (now, -056) +sql select * from st_smallint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_smallint_16 using mt_smallint tags (null) values (now, null) +sql describe st_smallint_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_16 +if $data01 != null then + return -1 +endi + +sql insert into st_smallint_17 using mt_smallint tags (NULL) values (now, NULL) +sql describe st_smallint_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_17 +if $data01 != null then + return -1 +endi +sql insert into st_smallint_18 using mt_smallint tags ('null') values (now, 'null') +sql describe st_smallint_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_18 +if $data01 != null then + return -1 +endi +sql insert into st_smallint_19 using mt_smallint tags ('NULL') values (now, 'NULL') +sql describe st_smallint_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_19 +if $data01 != null then + return -1 +endi +sql insert into st_smallint_20 using mt_smallint tags ("null") values (now, "null") +sql describe st_smallint_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_20 +if $data01 != null then + return -1 +endi +sql insert into st_smallint_21 using mt_smallint tags ("NULL") values (now, "NULL") +sql describe st_smallint_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_smallint_21 +if $data01 != null then + return -1 +endi +sql insert into st_smallint_22 using mt_smallint tags (32767) values (now, 32767) +sql describe st_smallint_22 +if $data23 != 32767 then + return -1 +endi +sql select * from st_smallint_22 +if $data01 != 32767 then + return -1 +endi +sql insert into st_smallint_23 using mt_smallint tags (-32767) values (now, -32767) +sql describe st_smallint_23 +if $data23 != -32767 then + return -1 +endi +sql select * from st_smallint_23 +if $data01 != -32767 then + return -1 +endi +sql insert into st_smallint_24 using mt_smallint tags (10) values (now, 10) +sql describe st_smallint_24 +if $data23 != 10 then + return -1 +endi +sql select * from st_smallint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_smallint_25 using mt_smallint tags ("-0") values (now, "-0") +sql describe st_smallint_25 +if $data23 != 0 then + return -1 +endi +sql select * from st_smallint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_smallint_26 using mt_smallint tags ('123') values (now, '123') +sql describe st_smallint_26 +if $data23 != 123 then + return -1 +endi +sql select * from st_smallint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_smallint_27 using mt_smallint tags (+056) values (now, +00056) +sql describe st_smallint_27 +if $data23 != 56 then + return -1 +endi +sql select * from st_smallint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_smallint_28 using mt_smallint tags (-056) values (now, -0056) +sql describe st_smallint_28 +if $data23 != -56 then + return -1 +endi +sql select * from st_smallint_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +sql alter table st_smallint_0 set tag tagname=32767 +sql describe st_smallint_0 +if $data23 != 32767 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname=-32767 +sql describe st_smallint_0 +if $data23 != -32767 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname=+100 +sql describe st_smallint_0 +if $data23 != 100 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname=-33 +sql describe st_smallint_0 +if $data23 != -33 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname='+98' +sql describe st_smallint_0 +if $data23 != 98 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname='-076' +sql describe st_smallint_0 +if $data23 != -76 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname=+0012 +sql describe st_smallint_0 +if $data23 != 12 then + return -1 +endi +sql alter table st_smallint_0 set tag tagname=-00063 +sql describe st_smallint_0 +if $data23 != -63 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_smallint_e0 using mt_smallint tags (32768) +sql_error create table st_smallint_e0 using mt_smallint tags (-32768) +sql_error create table st_smallint_e0 using mt_smallint tags (3276899) +sql_error create table st_smallint_e0 using mt_smallint tags (-3276833) +#sql_error create table st_smallint_e0 using mt_smallint tags (12.80) truncate integer part +#sql_error create table st_smallint_e0 using mt_smallint tags (-11.80) +sql_error create table st_smallint_e0 using mt_smallint tags (123abc) +sql_error create table st_smallint_e0 using mt_smallint tags ("123abc") +sql_error create table st_smallint_e0 using mt_smallint tags (abc) +sql_error create table st_smallint_e0 using mt_smallint tags ("abc") +sql_error create table st_smallint_e0 using mt_smallint tags (" ") +sql_error create table st_smallint_e0 using mt_smallint tags ('') + +sql create table st_smallint_e0 using mt_smallint tags (123) +sql create table st_smallint_e1 using mt_smallint tags (123) +sql create table st_smallint_e2 using mt_smallint tags (123) +sql create table st_smallint_e3 using mt_smallint tags (123) +sql create table st_smallint_e4 using mt_smallint tags (123) +sql create table st_smallint_e5 using mt_smallint tags (123) +sql create table st_smallint_e6 using mt_smallint tags (123) +sql create table st_smallint_e7 using mt_smallint tags (123) +sql create table st_smallint_e8 using mt_smallint tags (123) +sql create table st_smallint_e9 using mt_smallint tags (123) +sql create table st_smallint_e10 using mt_smallint tags (123) +sql create table st_smallint_e11 using mt_smallint tags (123) +sql create table st_smallint_e12 using mt_smallint tags (123) + +sql_error insert into st_smallint_e0 values (now, 32768) +sql_error insert into st_smallint_e1 values (now, -32768) +sql_error insert into st_smallint_e2 values (now, 42768) +sql_error insert into st_smallint_e3 values (now, -32769) +#sql_error insert into st_smallint_e4 values (now, 12.80) +#sql_error insert into st_smallint_e5 values (now, -11.80) +sql_error insert into st_smallint_e6 values (now, 123abc) +sql_error insert into st_smallint_e7 values (now, "123abc") +sql_error insert into st_smallint_e9 values (now, abc) +sql_error insert into st_smallint_e10 values (now, "abc") +sql_error insert into st_smallint_e11 values (now, " ") +sql_error insert into st_smallint_e12 values (now, '') + +sql_error insert into st_smallint_e13 using mt_smallint tags (033) values (now, 32768) +sql_error insert into st_smallint_e14 using mt_smallint tags (033) values (now, -32768) +sql_error insert into st_smallint_e15 using mt_smallint tags (033) values (now, 32968) +sql_error insert into st_smallint_e16 using mt_smallint tags (033) values (now, -33768) +#sql_error insert into st_smallint_e17 using mt_smallint tags (033) values (now, 12.80) +#sql_error insert into st_smallint_e18 using mt_smallint tags (033) values (now, -11.80) +sql_error insert into st_smallint_e19 using mt_smallint tags (033) values (now, 123abc) +sql_error insert into st_smallint_e20 using mt_smallint tags (033) values (now, "123abc") +sql_error insert into st_smallint_e22 using mt_smallint tags (033) values (now, abc) +sql_error insert into st_smallint_e23 using mt_smallint tags (033) values (now, "abc") +sql_error insert into st_smallint_e24 using mt_smallint tags (033) values (now, " ") +sql_error insert into st_smallint_e25 using mt_smallint tags (033) values (now, '') + +sql_error insert into st_smallint_e13 using mt_smallint tags (32768) values (now, -033) +sql_error insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033) +sql_error insert into st_smallint_e15 using mt_smallint tags (72768) values (now, -033) +sql_error insert into st_smallint_e16 using mt_smallint tags (-92768) values (now, -033) +#sql_error insert into st_smallint_e17 using mt_smallint tags (12.80) values (now, -033) +#sql_error insert into st_smallint_e18 using mt_smallint tags (-11.80) values (now, -033) +sql_error insert into st_smallint_e19 using mt_smallint tags (123abc) values (now, -033) +sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values (now, -033) +sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033) +sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033) +sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033) +sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) + +sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e15 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e16 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e17 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e18 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e19 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e20 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e21 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e22 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e23 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e24 using mt_smallint tags (033) values (now, 00062) +sql insert into st_smallint_e25 using mt_smallint tags (033) values (now, 00062) + +sql_error alter table st_smallint_e13 set tag tagname=32768 +sql_error alter table st_smallint_e14 set tag tagname=-32768 +sql_error alter table st_smallint_e15 set tag tagname=52768 +sql_error alter table st_smallint_e16 set tag tagname=-32778 +sql_error alter table st_smallint_e19 set tag tagname=123abc +sql_error alter table st_smallint_e20 set tag tagname="123abc" +sql_error alter table st_smallint_e22 set tag tagname=abc +sql_error alter table st_smallint_e23 set tag tagname="abc" +sql_error alter table st_smallint_e24 set tag tagname=" " +sql_error alter table st_smallint_e25 set tag tagname='' diff --git a/tests/script/general/parser/columnValue_tinyint.sim b/tests/script/general/parser/columnValue_tinyint.sim new file mode 100644 index 0000000000..f0d1b4e0c4 --- /dev/null +++ b/tests/script/general/parser/columnValue_tinyint.sim @@ -0,0 +1,465 @@ +sleep 3000 +sql connect +sql create database if not exists db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: tinyint +print ========== tinyint +sql create table mt_tinyint (ts timestamp, c tinyint) tags (tagname tinyint) + +## case 00: static create table for test tag values +sql create table st_tinyint_0 using mt_tinyint tags (null) +sql describe st_tinyint_0 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_1 using mt_tinyint tags (NULL) +sql describe st_tinyint_1 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_2 using mt_tinyint tags ('null') +sql describe st_tinyint_2 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_3 using mt_tinyint tags ('NULL') +sql describe st_tinyint_3 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_4 using mt_tinyint tags ("null") +sql describe st_tinyint_4 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql describe st_tinyint_5 +if $data23 != NULL then + return -1 +endi +sql create table st_tinyint_6 using mt_tinyint tags (-127) +sql describe st_tinyint_6 +if $data23 != -127 then + return -1 +endi +sql create table st_tinyint_7 using mt_tinyint tags (127) +sql describe st_tinyint_7 +if $data23 != 127 then + return -1 +endi +sql create table st_tinyint_8 using mt_tinyint tags (37) +sql describe st_tinyint_8 +if $data23 != 37 then + return -1 +endi +sql create table st_tinyint_9 using mt_tinyint tags (-100) +sql describe st_tinyint_9 +if $data23 != -100 then + return -1 +endi +sql create table st_tinyint_10 using mt_tinyint tags (+113) +sql describe st_tinyint_10 +if $data23 != 113 then + return -1 +endi +sql create table st_tinyint_11 using mt_tinyint tags ('-100') +sql describe st_tinyint_11 +if $data23 != -100 then + return -1 +endi +sql create table st_tinyint_12 using mt_tinyint tags ("+78") +sql describe st_tinyint_12 +if $data23 != 78 then + return -1 +endi +sql create table st_tinyint_13 using mt_tinyint tags (+0078) +sql describe st_tinyint_13 +if $data23 != 78 then + return -1 +endi +sql create table st_tinyint_14 using mt_tinyint tags (-00078) +sql describe st_tinyint_14 +if $data23 != -78 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_tinyint_0 values (now, null) +sql select * from st_tinyint_0 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_1 values (now, NULL) +sql select * from st_tinyint_1 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_2 values (now, 'null') +sql select * from st_tinyint_2 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_3 values (now, 'NULL') +sql select * from st_tinyint_3 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_4 values (now, "null") +sql select * from st_tinyint_4 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_5 values (now, "NULL") +sql select * from st_tinyint_5 +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_6 values (now, 127) +sql select * from st_tinyint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 127 then + return -1 +endi +sql insert into st_tinyint_7 values (now, -127) +sql select * from st_tinyint_7 +if $rows != 1 then + return -1 +endi +if $data01 != -127 then + return -1 +endi +sql insert into st_tinyint_8 values (now, +100) +sql select * from st_tinyint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_tinyint_9 values (now, "-098") +sql select * from st_tinyint_9 +if $rows != 1 then + return -1 +endi +if $data01 != -98 then + return -1 +endi +sql insert into st_tinyint_10 values (now, '0') +sql select * from st_tinyint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_11 values (now, -0) +sql select * from st_tinyint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_12 values (now, "+056") +sql select * from st_tinyint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_tinyint_13 values (now, +056) +sql select * from st_tinyint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_tinyint_14 values (now, -056) +sql select * from st_tinyint_14 +if $rows != 1 then + return -1 +endi +if $data01 != -56 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_tinyint_16 using mt_tinyint tags (null) values (now, null) +sql describe st_tinyint_16 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_16 +if $data01 != null then + return -1 +endi + +sql insert into st_tinyint_17 using mt_tinyint tags (NULL) values (now, NULL) +sql describe st_tinyint_17 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_17 +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_18 using mt_tinyint tags ('null') values (now, 'null') +sql describe st_tinyint_18 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_18 +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_19 using mt_tinyint tags ('NULL') values (now, 'NULL') +sql describe st_tinyint_19 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_19 +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_20 using mt_tinyint tags ("null") values (now, "null") +sql describe st_tinyint_20 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_20 +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_21 using mt_tinyint tags ("NULL") values (now, "NULL") +sql describe st_tinyint_21 +if $data23 != NULL then + return -1 +endi +sql select * from st_tinyint_21 +if $data01 != null then + return -1 +endi +sql insert into st_tinyint_22 using mt_tinyint tags (127) values (now, 127) +sql describe st_tinyint_22 +if $data23 != 127 then + return -1 +endi +sql select * from st_tinyint_22 +if $data01 != 127 then + return -1 +endi +sql insert into st_tinyint_23 using mt_tinyint tags (-127) values (now, -127) +sql describe st_tinyint_23 +if $data23 != -127 then + return -1 +endi +sql select * from st_tinyint_23 +if $data01 != -127 then + return -1 +endi +sql insert into st_tinyint_24 using mt_tinyint tags (10) values (now, 10) +sql describe st_tinyint_24 +if $data23 != 10 then + return -1 +endi +sql select * from st_tinyint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_tinyint_25 using mt_tinyint tags ("-0") values (now, "-0") +sql describe st_tinyint_25 +if $data23 != 0 then + return -1 +endi +sql select * from st_tinyint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_tinyint_26 using mt_tinyint tags ('123') values (now, '123') +sql describe st_tinyint_26 +if $data23 != 123 then + return -1 +endi +sql select * from st_tinyint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_tinyint_27 using mt_tinyint tags (+056) values (now, +00056) +sql describe st_tinyint_27 +if $data23 != 56 then + return -1 +endi +sql select * from st_tinyint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_tinyint_28 using mt_tinyint tags (-056) values (now, -0056) +sql describe st_tinyint_28 +if $data23 != -56 then + return -1 +endi +sql select * from st_tinyint_28 +if $data01 != -56 then + return -1 +endi + +## case 03: alter tag values +sql alter table st_tinyint_0 set tag tagname=127 +sql describe st_tinyint_0 +if $data23 != 127 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname=-127 +sql describe st_tinyint_0 +if $data23 != -127 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname=+100 +sql describe st_tinyint_0 +if $data23 != 100 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname=-33 +sql describe st_tinyint_0 +if $data23 != -33 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname='+98' +sql describe st_tinyint_0 +if $data23 != 98 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname='-076' +sql describe st_tinyint_0 +if $data23 != -76 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname=+0012 +sql describe st_tinyint_0 +if $data23 != 12 then + return -1 +endi +sql alter table st_tinyint_0 set tag tagname=-00063 +sql describe st_tinyint_0 +if $data23 != -63 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_tinyint_e0 using mt_tinyint tags (128) +sql_error create table st_tinyint_e0 using mt_tinyint tags (-128) +sql_error create table st_tinyint_e0 using mt_tinyint tags (1280) +sql_error create table st_tinyint_e0 using mt_tinyint tags (-1280) +#sql_error create table st_tinyint_e0 using mt_tinyint tags (12.80) truncate integer part +#sql_error create table st_tinyint_e0 using mt_tinyint tags (-11.80) +sql_error create table st_tinyint_e0 using mt_tinyint tags (123abc) +sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc") +sql_error create table st_tinyint_e0 using mt_tinyint tags (abc) +sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc") +sql_error create table st_tinyint_e0 using mt_tinyint tags (" ") +sql_error create table st_tinyint_e0 using mt_tinyint tags ('') + +sql create table st_tinyint_e0 using mt_tinyint tags (123) +sql create table st_tinyint_e1 using mt_tinyint tags (123) +sql create table st_tinyint_e2 using mt_tinyint tags (123) +sql create table st_tinyint_e3 using mt_tinyint tags (123) +sql create table st_tinyint_e4 using mt_tinyint tags (123) +sql create table st_tinyint_e5 using mt_tinyint tags (123) +sql create table st_tinyint_e6 using mt_tinyint tags (123) +sql create table st_tinyint_e7 using mt_tinyint tags (123) +sql create table st_tinyint_e8 using mt_tinyint tags (123) +sql create table st_tinyint_e9 using mt_tinyint tags (123) +sql create table st_tinyint_e10 using mt_tinyint tags (123) +sql create table st_tinyint_e11 using mt_tinyint tags (123) +sql create table st_tinyint_e12 using mt_tinyint tags (123) + +sql_error insert into st_tinyint_e0 values (now, 128) +sql_error insert into st_tinyint_e1 values (now, -128) +sql_error insert into st_tinyint_e2 values (now, 1280) +sql_error insert into st_tinyint_e3 values (now, -1280) +#sql_error insert into st_tinyint_e4 values (now, 12.80) +#sql_error insert into st_tinyint_e5 values (now, -11.80) +sql_error insert into st_tinyint_e6 values (now, 123abc) +sql_error insert into st_tinyint_e7 values (now, "123abc") +sql_error insert into st_tinyint_e9 values (now, abc) +sql_error insert into st_tinyint_e10 values (now, "abc") +sql_error insert into st_tinyint_e11 values (now, " ") +sql_error insert into st_tinyint_e12 values (now, '') + +sql_error insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 128) +sql_error insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, -128) +sql_error insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 1280) +sql_error insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, -1280) +#sql_error insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 12.80) +#sql_error insert into st_tinyint_e18 using mt_tinyint tags (033) values (now, -11.80) +sql_error insert into st_tinyint_e19 using mt_tinyint tags (033) values (now, 123abc) +sql_error insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, "123abc") +sql_error insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, abc) +sql_error insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, "abc") +sql_error insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, " ") +sql_error insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, '') + +sql_error insert into st_tinyint_e13 using mt_tinyint tags (128) values (now, -033) +sql_error insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033) +sql_error insert into st_tinyint_e15 using mt_tinyint tags (1280) values (now, -033) +sql_error insert into st_tinyint_e16 using mt_tinyint tags (-1280) values (now, -033) +#sql_error insert into st_tinyint_e17 using mt_tinyint tags (12.80) values (now, -033) +#sql_error insert into st_tinyint_e18 using mt_tinyint tags (-11.80) values (now, -033) +sql_error insert into st_tinyint_e19 using mt_tinyint tags (123abc) values (now, -033) +sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (now, -033) +sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033) +sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033) +sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033) +sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) + +sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e18 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e19 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e21 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, 00062) +sql insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, 00062) + +sql_error alter table st_tinyint_e13 set tag tagname=128 +sql_error alter table st_tinyint_e14 set tag tagname=-128 +sql_error alter table st_tinyint_e15 set tag tagname=1280 +sql_error alter table st_tinyint_e16 set tag tagname=-1280 +sql_error alter table st_tinyint_e19 set tag tagname=123abc +sql_error alter table st_tinyint_e20 set tag tagname="123abc" +sql_error alter table st_tinyint_e22 set tag tagname=abc +sql_error alter table st_tinyint_e23 set tag tagname="abc" +sql_error alter table st_tinyint_e24 set tag tagname=" " +sql_error alter table st_tinyint_e25 set tag tagname='' diff --git a/tests/script/general/parser/commit.sim b/tests/script/general/parser/commit.sim new file mode 100644 index 0000000000..61faad1864 --- /dev/null +++ b/tests/script/general/parser/commit.sim @@ -0,0 +1,109 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = sc_db +$tbPrefix = sc_tb +$stbPrefix = sc_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$loops = 5 +$log = 1 +$ts0 = 1537146000000 +$delta = 600000 +print ========== commit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db rows 255 ablocks 1024 tblocks 512 tables 100 ctime 3600 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql use $db +##### select from table +print ====== select from table and check num of rows returned +$loop = 1 +$i = 0 +while $loop <= $loops + print repeat = $loop + while $i < 10 + sql select count(*) from $stb where t1 = $i + if $data00 != $rowNum then + return -1 + endi + $i = $i + 1 + endw + sql select count(*) from $stb + if $data00 != $totalNum then + return -1 + endi + $loop = $loop + 1 +endw + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +print ================== server restart completed +sql connect +sleep 3000 + +print ====== select from table and check num of rows returned +sql use $db +$loop = 1 +$i = 0 +while $loop <= $loops + print repeat = $loop + while $i < 10 + sql select count(*) from $stb where t1 = $i + if $data00 != $rowNum then + return -1 + endi + $i = $i + 1 + endw + sql select count(*) from $stb + if $data00 != $totalNum then + return -1 + endi + $loop = $loop + 1 +endw diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim new file mode 100644 index 0000000000..9bfeef7355 --- /dev/null +++ b/tests/script/general/parser/create_db.sim @@ -0,0 +1,190 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_db.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql_error createdatabase $db +sql create database $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db + +# case1: case_insensitivity test +print =========== create_db.sim case1: case insensitivity test +sql_error CREATEDATABASE $db +sql CREATE DATABASE $db +sql use $db +sql show databases + +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +sql drop database $db +print case_insensitivity test passed + +# case2: illegal_db_name test +print =========== create_db.sim case2: illegal_db_name test +$illegal_db1 = 1db +$illegal_db2 = d@b + +sql_error create database $illegal_db1 +sql_error create database $illegal_db2 +print illegal_db_name test passed + +# case3: chinese_char_in_db_name test +print ========== create_db.sim case3: chinese_char_in_db_name test +$CN_db1 = æ•°æ®åº“ +$CN_db2 = æ•°æ®åº“1 +$CN_db3 = dbæ•°æ®åº“1 +sql_error create database $CN_db1 +sql_error create database $CN_db2 +sql_error create database $CN_db3 +#sql show databases +#if $rows != 3 then +# return -1 +#endi +#if $data00 != $CN_db1 then +# return -1 +#endi +#if $data10 != $CN_db2 then +# return -1 +#endi +#if $data20 != $CN_db3 then +# return -1 +#endi +#sql drop database $CN_db1 +#sql drop database $CN_db2 +#sql drop database $CN_db3 +print case_chinese_char_in_db_name test passed + +# case4: db_already_exists +print create_db.sim case4: db_already_exists +sql create database db0 +sql create database db0 +sql show databases +if $rows != 1 then + return -1 +endi +sql drop database db0 +print db_already_exists test passed + +# case5: db_meta_data +print create_db.sim case5: db_meta_data test +# cfg params +$replica = 1 # max=3 +$days = 10 +$keep = 365 +$rows_db = 1000 +$cache = 4096 # 4 kb +$ablocks = 100 +$tblocks = 32 # max=512, automatically trimmed when exceeding +$ctime = 36000 # 10 hours +$clog = 0 # max=32, automatically trimmed when exceeding +$comp = 1 # max=32, automatically trimmed when exceeding + +sql create database $db replica $replica days $days keep $keep rows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime clog $clog comp $comp +sql show databases +if $rows != 1 then + return -1 +endi +if $data00 != $db then + return -1 +endi +if $data04 != $replica then + return -1 +endi +if $data05 != $days then + return -1 +endi +if $data06 != 365,365,365 then + return -1 +endi +print data08 = $data08 +if $data08 != $rows_db then + return -1 +endi +if $data09 != $cache then + return -1 +endi +sql drop database $db + +# ablocks_smaller_than_tblocks +#$ablocks = 50 +#$tblocks = 100 +#sql_error create database $db ablocks $ablocks tblocks $tblocks + +## param range tests +# replica [1,3] +#sql_error create database $db replica 0 +sql_error create database $db replica 4 + +# day [1, 3650] +sql_error create database $db day 0 +sql_error create database $db day 3651 + +# keep [1, infinity] +sql_error create database $db keep 0 +#sql_error create database $db keep 3651 + +# rows [200, 10000] +sql_error create database $db rows 199 +#sql_error create database $db rows 10001 + +# cache [100, 10485760] +sql_error create database $db cache 99 +#sql_error create database $db cache 10485761 + +# ablocks [overwriten by 4*sessionsPerVnode, 409600] +sql_error create database $db ablocks -1 +#sql_error create database $db ablocks 409601 + +# tblocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] +#sql_error create database $db tblocks 31 +#sql_error create database $db tblocks 4097 + +# ctime [30, 40960] +sql_error create database $db ctime 29 +sql_error create database $db ctime 40961 + +# clog {0, 1} +sql_error create database $db clog -1 +#sql_error create database $db clog 2 + +# comp {0, 1, 2} +sql_error create database $db comp -1 +sql_error create database $db comp 3 + +sql_error drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim new file mode 100644 index 0000000000..486a1e3fc8 --- /dev/null +++ b/tests/script/general/parser/create_mt.sim @@ -0,0 +1,260 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print excuting test script create_mt.sim +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +# case1: case_insensitivity test +print =========== create_mt.sim case1: case insensitivity test +sql CREATE TABLE $mt (TS TIMESTAMP, COL1 INT, COL2 BIGINT, COL3 FLOAT, COL4 DOUBLE, COL5 BINARY(10), COL6 BOOL, COL7 SMALLINT, COL8 TINYINT, COL9 NCHAR(10)) TAGS (TAG1 INT, TAG2 BIGINT, TAG3 DOUBLE, TAG4 BINARY(10), TAG5 BOOL, TAG6 NCHAR(10)) +sql show stables + +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql_error DROP METRIC $mt + +sql DROP TABLE $mt +sql show stables + +if $rows != 0 then + return -1 +endi +print data00 = $data00 +if $data00 != null then + return -1 +endi +print case_insensitivity test passed + +# case2: illegal_metric_name test +print =========== create_mt.sim case2: illegal_mt_name test +$illegal_tb1 = 1db +$illegal_tb2 = d@b + +sql_error create table $illegal_tb1 (ts timestamp, tcol int) tags (tag1 int) + +sql_error create table $illegal_tb2 (ts timestamp, tcol int) tags (tag1 int) + +print illegal_metric_name test passed + +## case3: illegal_data_types_in_data_column test +print ========== create_mt.sim case3: metric illegal data types test + +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$i_nchar = nchar # unspecified nchar length + +sql_error create table $mt (ts $i_ts , col int) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_binary ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_bigint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_smallint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_binary2 ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_tinyint ) tags (tag1 int) +sql_error create table $mt (ts timestamp, col $i_nchar ) tags (tag1 int) + +# correct using of nchar +sql create table $mt (ts timestamp, col nchar(10)) tags (tag1 int) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql drop table $mt +print illegal_data_type_in_tags test passed + +## case4: illegal_data_type_in_tags test +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$i_bool = boolean +$nchar = nchar # nchar with unspecified length +print ========== create_mt.sim case4: illegal data types in tags test +sql_error create table $mt (ts timestamp, col int) tags (tag1 timestamp ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_ts ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bigint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_smallint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_tinyint ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary2 ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bool ) +sql_error create table $mt (ts timestamp, col int) tags (tag1 $nchar ) +# correct use of nchar in tags +sql create table $mt (ts timestamp, col int) tags (tag1 nchar(20)) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql drop table $mt +print illegal_data_type_in_tags test passed + +# illegal_tag_name test +# Only frequently used key words are tested here +$tb_ = table +$tbs = tables +$db_ = database +$dbs = databases +$mt_ = metric +$mts = metrics +$int = int +$bint = bigint +$binary = binary +$str = string +$tag = tag +$tags = tags +$sint = smallint +$tint = tinyint +$nchar = nchar +$bool = bool +$stable = stable +$stables = stables + +sql_error create table $mt (ts timestamp, col1 int) tags ( $tb_ int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tbs int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $db_ int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $dbs int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $mt_ int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $mts int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $int int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $bint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $binary int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $str int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tag int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tags int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $sint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $tint int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $nchar int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $stable int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $stables int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $bool int) + +print illegal_column_name test passed + +# case: negative tag values +sql create table $mt (ts timestamp, col1 int) tags (tg int) +sql create table $tb using $mt tags (-1) +# -x ng_tag_v +# return -1 +#ng_tag_v: +sql describe $tb +if $data23 != -1 then + return -1 +endi +sql drop table $tb + +# case: unmatched_tag_types +print create_mt.sim unmatched_tag_types +sql reset query cache +sql create table $tb using $mt tags ('123') +sql describe $tb +#print data23 = $data23 +if $data23 != 123 then + return -1 +endi +sql drop table $tb +sql_error create table $tb using $mt tags (abc) +#the case below might need more consideration +sql_error create table $tb using $mt tags ('abc') +sql drop table if exists $tb +sql reset query cache +sql create table $tb using $mt tags (1e1) +sql describe $tb +if $data23 != 10 then + return -1 +endi +sql drop table $tb +sql create table $tb using $mt tags ('1e1') +sql describe $tb +if $data23 != 10 then + return -1 +endi +sql_error create table $tb using $mt tags (2147483649) + +## case: chinese_char_in_metric +print ========== create_mt.sim chinese_char_in_metrics_support test +$CN_char = æ¶›æ€ +$mt1 = mt1 +$mt2 = mt2 +# no chinese char allowed in db, metric, table, column names +#sql_error create table $CN_char (ts timestamp, col1 int) tags (tag1 int) +#sql_error create table $mt1 (ts timestamp, $CN_char int) tags (tag1 int) +#sql_error create table $mt2 (ts timestamp, col1 int) tags ( $CN_char int) +#sql show metrics +#if $rows != 3 then +# return -1 +#endi +##print expected: $CN_char +##print returned: $data00 +#if $data00 != $CN_char then +# return -1 +#endi +##print expected: $mt1 +##print returned: $data10 +#if $data10 != $mt1 then +# return -1 +#endi +##print expected: $mt2 +##print returned: $data20 +#if $data20 != $mt2 then +# return -1 +#endi +#sql describe $mt1 +##print expected $CN_char +##print returned $data10 +#if $data10 != $CN_char then +# return -1 +#endi +#sql describe $mt2 +##print expected: $CN_char +##print returned: $data20 +#if $data20 != $CN_char then +# return -1 +#endi +# +#sql drop table $CN_char +#sql drop table $mt1 +#sql drop table $mt2 + +print chinese_char_in_metrics test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim new file mode 100644 index 0000000000..489780130a --- /dev/null +++ b/tests/script/general/parser/create_tb.sim @@ -0,0 +1,190 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db + +# case1: case_insensitivity test +print =========== create_tb.sim case1: case_insensitivity test +sql CREATE TABLE $tb (TS TIMESTAMP, COL1 INT, COL2 BIGINT, COL3 FLOAT, COL4 DOUBLE, COL5 BINARY(10), COL6 BOOL, COL7 SMALLINT, COL8 TINYINT, COL9 NCHAR(10)); +sql show tables + +if $rows != 1 then + return -1 +endi +print data00 = $data00 +if $data00 != $tb then + return -1 +endi +sql DROP TABLE $tb +sql show tables + +if $rows != 0 then + return -1 +endi +print data00 = $data00 +if $data00 != null then + return -1 +endi +print case_insensitivity test passed + +# case2: illegal_table_name test +print =========== create_tb.sim case2: illegal_table_name test +$illegal_tb1 = 1db +$illegal_tb2 = d@b + +sql_error create table $illegal_db1 (ts timestamp, tcol int) +sql_error create table $illegal_db2 (ts timestamp, tcol int) +print illegal_table_name test passed + +# case3: illegal_data_types +print ========== create_tb.sim case3: illegal_data_types test +$i_ts = time # illegal ts +$i_binary = binary # illegal binary +$i_bigint = long # illegal bigint +$i_smallint = short # illegal smallint +$i_tinyint = byte # illegal tinyint +$i_binary2 = varchar(20) # illegal string +$nchar = nchar # unspecified nchar length + +sql_error create table $tb (ts $i_ts , col int) +sql_error create table $tb (ts timestamp, col $i_binary ) +sql_error create table $tb (ts timestamp, col $i_bigint ) +sql_error create table $tb (ts timestamp, col $i_smallint ) +sql_error create table $tb (ts timestamp, col $i_tinyint ) +sql_error create table $tb (ts timestamp, col $i_binary2 ) +sql_error create table $tb (ts timestamp, col $nchar ) +sql create table $tb (ts timestamp, col nchar(20)) +sql show tables +if $rows != 1 then + return -1 +endi +if $data00 != $tb then + return -1 +endi +sql drop table $tb +print illegal data type test passed + +# case4: illegal_column_names +# Only frequently used key words are tested here +print ========== create_tb.sim case4: illegal_column_names +$tb_ = table +$tbs = tables +$db_ = database +$dbs = databases +$mt_ = metric +$mts = metrics +$int = int +$bint = bigint +$binary = binary +$str = string +$tag = tag +$tags = tags +$sint = smallint +$tint = tinyint +$nchar = nchar + +sql_error create table $tb (ts timestamp, $tb_ int) +sql_error create table $tb (ts timestamp, $tbs int) +sql_error create table $tb (ts timestamp, $db_ int) +sql_error create table $tb (ts timestamp, $dbs int) +sql_error create table $tb (ts timestamp, $mt_ int) +sql_error create table $tb (ts timestamp, $mts int) +sql_error create table $tb (ts timestamp, $int int) +sql_error create table $tb (ts timestamp, $bint int) +sql_error create table $tb (ts timestamp, $binary int) +sql_error create table $tb (ts timestamp, $str int) +sql_error create table $tb (ts timestamp, $tag int) +sql_error create table $tb (ts timestamp, $tags int) +sql_error create table $tb (ts timestamp, $sint int) +sql_error create table $tb (ts timestamp, $tint int) +sql_error create table $tb (ts timestamp, $nchar int) +print illegal_column_names test passed + +# case5: chinese_char_in_table_support +print ========== create_tb.sim case5: chinese_char_in_table_support test + +$CN_char = æ¶›æ€ +$tb1 = tb1 +sql_error create table $CN_char (ts timestamp, col1 int) +#sql show tables +#if $rows != 1 then +# return -1 +#endi +#print expected: $CN_char +#print returned: $data00 +#if $data00 != $CN_char then +# return -1 +#endi +#sql drop table $CN_char + +sql_error create table $tb1 (ts timestamp, $CN_char int) +#print expected: $tb1 +#print returned: $data10 +#sql show tables +#if $rows != 1 then +# return -1 +#endi +#if $data00 != $tb1 then +# return -1 +#endi +#sql describe $tb1 +##print expected $CN_char +##print returned $data10 +#if $data10 != $CN_char then +# return -1 +#endi +#sql drop table $tb1 +print chinese_char_in_table_support test passed + +# case6: table_already_exists +print ========== create_tb.sim case6: table_already_exists +sql create table tbs (ts timestamp, col int) +sql insert into tbs values (now, 1) +sql create table tbs (ts timestamp, col bool) +#sql_error create table tb (ts timestamp, col bool) +print table_already_exists test passed + +# case7: table_name_length_exceeds_limit +print ========== create_tb.sim case7: table_name_length_exceeds_limit +$tbname32 = _32_aaaabbbbccccddddaaaabbbbcccc +$tbname64 = _64_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccc +$tbname63 = _63_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbccc +$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca +sql create table $tbname32 (ts timestamp, col int) +sql insert into $tbname32 values (now, 1) +sql create table $tbname64 (ts timestamp, col int) +sql insert into $tbname64 values (now, 1) +sql create table $tbname63 (ts timestamp, col int) +sql insert into $tbname63 values (now, 1) +sql_error create table $tbname65 (ts timestamp, col int) +#sql_error create table tb (ts timestamp, col bool) +print table_already_exists test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/general/parser/dbtbnameValidate.sim new file mode 100644 index 0000000000..0ec5f3c9aa --- /dev/null +++ b/tests/script/general/parser/dbtbnameValidate.sim @@ -0,0 +1,131 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +print ========== db name and table name check in create and drop, describe +sql create database abc keep 36500 +sql create database 'abc123' +sql create database '_ab1234' +sql create database 'ABC123' +sql create database '_ABC123' +sql create database 'aABb123 ' +sql create database ' xyz ' +sql create database ' XYZ ' + +sql use 'abc123' +sql use '_ab1234' +sql use 'ABC123' +sql use '_ABC123' +sql use 'aABb123' +sql use ' xyz ' +sql use ' XYZ ' + +sql drop database 'abc123' +sql drop database '_ab1234' +sql drop database 'ABC123' +sql drop database '_ABC123' +sql drop database 'aABb123' +sql drop database ' xyz ' +sql drop database ' XYZ ' + + +sql use abc + +sql create table abc.cc (ts timestamp, c int) +sql create table 'abc.Dd' (ts timestamp, c int) +sql create table 'abc'.ee (ts timestamp, c int) +sql create table 'abc'.'FF' (ts timestamp, c int) +sql create table abc.'gG' (ts timestamp, c int) + +sql_error create table table.'a1' (ts timestamp, c int) +sql_error create table 'table'.'b1' (ts timestamp, c int) +sql_error create table 'table'.'b1' (ts timestamp, c int) + + +sql create table mt (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) +sql create table sub_001 using mt tags ( 1 , 'tag_nchar' , 'tag_bianry' , 4 , 5 , 6.1 ) +sql_error create table sub_002 using mt tags( 2 , tag_nchar , tag_bianry , 4 , 5 , 6.2 ) +sql insert into sub_dy_tbl using mt tags ( 3 , 'tag_nchar' , 'tag_bianry' , 4 , 5 , 6.3 ) values (now, 1, 2, 3.01, 4.02, 5, 6, true, 'binary_8', 'nchar_9') + +sql describe abc.cc +sql describe 'abc.Dd' +sql describe 'abc'.ee +sql describe 'abc'.'FF' +sql describe abc.'gG' + +sql describe cc +sql describe 'Dd' +sql describe ee +sql describe 'FF' +sql describe 'gG' + +sql describe mt +sql describe sub_001 +sql describe sub_dy_tbl + +sql_error describe Dd +sql_error describe FF +sql_error describe gG + +sql drop table abc.cc +sql drop table 'abc.Dd' +sql drop table 'abc'.ee +sql drop table 'abc'.'FF' +sql drop table abc.'gG' + +sql drop table sub_001 + +sql drop table sub_dy_tbl +sql drop table mt + +print ========== insert data by multi-format +sql create table abc.tk_mt (ts timestamp, a int, b binary(16), c bool, d float, e double, f nchar(16)) tags (t1 int, t2 binary(16)) + +sql create table abc.tk_subt001 using tk_mt tags(1, 'subt001') +sql insert into abc.tk_subt001 values (now-1y, 1, 'binary_1', true, 1.001, 2.001, 'nchar_1') +sql insert into abc.tk_subt001 values (now-1n, 2, 'binary_2', true, 1.002, 2.002, 'nchar_2') +sql insert into abc.tk_subt001 values (now-1w, 3, 'binary_3', true, 1.003, 2.003, 'nchar_3') +sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1d, 4, false, 2.004, 'nchar_4') +sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1h, 5, false, 2.005, 'nchar_5') +sql insert into abc.tk_subt001 (ts, b, d) values (now-1m, 'binary_6', 1.006) +sql insert into abc.tk_subt001 (ts, b, d) values (now-1s, 'binary_7', 1.007) +sql insert into abc.tk_subt001 (ts, b, d) values (now-1a, 'binary_8', 1.008) +sql select * from tk_subt001 +if $rows != 8 then + print ==== expect rows is 8, but actually is $rows + return -1 +endi + +sql insert into abc.tk_subt002 using tk_mt tags (22,'subt002x') values (now-2y, 2008, 'binary_2008', false, 2008.001, 2008.001, 'nchar_2008') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now-1y, 2007, 'binary_2007', false, 2007.001, 2007.001, 'nchar_2007') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now-1n, 2006, 'binary_2006', true, 2006.001, 2006.001, 'nchar_2006') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1s, 2001, 'binary_2001', true, 2001.001, 2001.001, 'nchar_2001') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1m, 2002, 'binary_2002', false, 2002.001, 2002.001, 'nchar_2002') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1h, 2003, 'binary_2003', false, 2003.001, 2003.001, 'nchar_2003') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1d, 2004, 'binary_2004', true, 2004.001, 2004.001, 'nchar_2004') +sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1w, 2005, 'binary_2005', false, 2005.001, 2005.001, 'nchar_2005') +sql select * from tk_subt002 +if $rows != 8 then + print ==== expect rows is 8, but actually is $rows + return -1 +endi + +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-5y, 3001, false, 3001.001, 'nchar_3001') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-4y, 3002, false, 3002.001, 'nchar_3002') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-3y, 3003, true , 3003.001, 'nchar_3003') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-2y, 3004, false, 3004.001, 'nchar_3004') +sql insert into abc.tk_subt003 values (now-37d, 3005, 'binary_3005', false, 3005.001, 3005.001, 'nchar_3005') +sql insert into abc.tk_subt003 values (now-36d, 3006, 'binary_3006', true, 3006.001, 3006.001, 'nchar_3006') +sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (33, 'subt003x') values (now-35d, 3007, false, 3007.001, 'nchar_3007') +sql select * from tk_subt003 +if $rows != 7 then + print ==== expect rows is 7, but actually is $rows + return -1 +endi + + + diff --git a/tests/script/general/parser/fill.sim b/tests/script/general/parser/fill.sim new file mode 100644 index 0000000000..89e35e1a38 --- /dev/null +++ b/tests/script/general/parser/fill.sim @@ -0,0 +1,851 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = m_fl_db +$tbPrefix = m_fl_tb +$mtPrefix = m_fl_mt +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== fill.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 bool, c7 binary(10), c8 nchar(10)) tags(tgcol int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +# setup +$i = 0 +$tb = $tbPrefix . $i +$tsu = 4 * $delta +$tsu = $tsu + $ts0 + +## fill syntax test +# number of fill values exceeds number of selected columns +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data14 != 6.000000000 then + return -1 +endi + +# number of fill values is smaller than number of selected columns +sql select max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi + +# unspecified filling method +sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) + +## constant fill test +# count_with_fill +print constant_fill test +print count_with_constant_fill +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +print avg_witt_constant_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 6.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 6.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 6.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 6.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +print max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +print min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +print first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# check double type values +if $data04 != 0.000000000 then + return -1 +endi +print data14 = $data14 +if $data14 != 6.000000000 then + return -1 +endi +if $data24 != 1.000000000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data44 != 2.000000000 then + return -1 +endi +if $data54 != 6.000000000 then + return -1 +endi +if $data64 != 3.000000000 then + return -1 +endi + +# check float type values +print $data03 $data13 +if $data03 != 0.00000 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi +if $data23 != 1.00000 then + return -1 +endi +if $data33 != 6.00000 then + return -1 +endi +if $data43 != 2.00000 then + return -1 +endi +if $data53 != 6.00000 then + return -1 +endi +if $data63 != 3.00000 then + return -1 +endi +if $data73 != 6.00000 then + return -1 +endi +if $data83 != 4.00000 then + return -1 +endi + + +# last_with_fill +print last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 6 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# fill_negative_values +sql select sum(c1), avg(c2), max(c3), min(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -1, -1, -1, -1, -1, -1, -1) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +# fill_char_values_to_arithmetic_fields +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') + +# fill_multiple_columns +sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) +sql select sum(c1), avg(c2), min(c3), max(c4) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99) +if $rows != 9 then + return -1 +endi +print data01 = $data01 +print data11 = $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 99 then + return -1 +endi + +sql select * from $tb +#print data08 = $data08 +if $data08 != NCHAR then + return -1 +endi +#return -1 + + +# fill_into_nonarithmetic_fieds +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) +#if $data11 != 20000000 then +if $data11 != 1 then + return -1 +endi + +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') +# fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 +# fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') + + +# fill nonarithmetic values into arithmetic fields +sql_error select count(*) where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); +sql_error select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + + +## linear fill +# feature currently switched off 2018/09/29 +#sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) + +## previous fill +print fill(prev) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != 1 then + return -1 +endi +if $data81 != 1 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != 0.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != 1.000000000 then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != 2.000000000 then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != 3.000000000 then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != 2 then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != 3 then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +## NULL fill +print fill(value, NULL) +# count_with_fill +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +print select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill( NULL) +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 1 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6), count(c7), count(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(none) +if $rows != 5 then + return -1 +endi + +# avg_with_fill +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 2.000000000 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 3.000000000 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 4.000000000 then + return -1 +endi + +# max_with_fill +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# min_with_fill +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# first_with_fill +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +# last_with_fill +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, NULL) +if $rows != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data51 != null then + return -1 +endi +if $data61 != 3 then + return -1 +endi +if $data71 != null then + return -1 +endi +if $data81 != 4 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/fill_stb.sim b/tests/script/general/parser/fill_stb.sim new file mode 100644 index 0000000000..0740ab64fa --- /dev/null +++ b/tests/script/general/parser/fill_stb.sim @@ -0,0 +1,432 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = fl1_db +$tbPrefix = fl1_tb +$stbPrefix = fl1_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== fill.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 bool, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +# setup +$i = 0 +$tb = $tbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +#### fill test cases for stables + +# null values in each group +#sql select count(*) from $stb where ts >= '2018-09-16 00:00:00.000' and ts <= $tsu interval(1d) fill(prev) group by t1 +#$val = $tbNum * 2 +#if rows != $val then +# return -1 +#endi +#if $data00 != @18-09-16 00:00:00.000@ then +# return -1 +#endi +#if $data01 != NULL then +# return -1 +#endi +#if $data02 != NULL then +# return -1 +#endi +#if $data11 != $rowNum then +# return -1 +#endi +#if $data12 != 0 then +# return -1 +#endi +#if $data20 != @18-09-16 00:00:00.000@ then +# return -1 +#endi +#if $data21 != NULL then +# return -1 +#endi +#if $data22 != NULL then +# return -1 +#endi + +# number of fill values exceeds number of selected columns +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -3.00000 then + return -1 +endi +if $data14 != -4.000000000 then + return -1 +endi +if $data15 != -5 then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data52 != -2 then + return -1 +endi +if $data73 != -3.00000 then + return -1 +endi +if $data74 != -4.000000000 then + return -1 +endi +## fill(value) + group by +sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) group by t1 +$val = $rowNum * 2 +$val = $val - 1 +$val = $val * $tbNum +if $rows != $val then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi +#if $data16 != 0 then +# return -1 +#endi + +# number of fill values is smaller than number of selected columns +sql select max(c1), max(c2), max(c3) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) +if $data11 != 6 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 6.00000 then + return -1 +endi + +# unspecified filling method +sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) + +# fill_char_values_to_arithmetic_fields +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') + +# fill_multiple_columns +sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) +sql select sum(c1), avg(c2), min(c3), max(c4) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 99 then + return -1 +endi + +sql select * from $stb +#print data08 = $data08 +if $data09 != nchar0 then + return -1 +endi +sql select max(c4) from $stb where t1 > 4 and ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) group by t1 +if $rows != 0 then + return -1 +endi +sql select min(c1), max(c4) from $stb where t1 > 4 and ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != -1.000000000 then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -1.000000000 then + return -1 +endi + +# fill_into_nonarithmetic_fieds +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) +#if $data11 != 20000000 then +if $data11 != 1 then + return -1 +endi + +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql select first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') +# fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 +# fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 +sql_error select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') + + +# fill nonarithmetic values into arithmetic fields +sql_error select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); +sql_error select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '2e1'); +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 2e1); +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +sql select count(*) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '20'); +if $rows != $val then + return -1 +endi +if $data01 != $rowNum then + return -1 +endi +if $data11 != 20 then + return -1 +endi + +## linear fill +sql select max(c1), min(c2), avg(c3), sum(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) group by t1 +$val = $rowNum * 2 +$val = $val - 1 +$val = $val * $tbNum +if $rows != $val then + return -1 +endi +if $data08 != 0 then + return -1 +endi +if $data15 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != 0 then + return -1 +endi + +## [TBASE-365] +sql select max(c1), min(c2), avg(c3), sum(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(linear) group by t1 +if $rows != 95 then + return -1 +endi +#if $data02 != NULL then +# return -1 +#endi +#if $data04 != NULL then +# return -1 +#endi +if $data06 != binary0 then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data08 != 5 then + return -1 +endi +if $data18 != 5 then + return -1 +endi + +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) +$val = $rowNum * 2 +$val = $val - 1 +if $rows != $val then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi +if $data17 != null then + return -1 +endi + +sql select max(c1), min(c2), sum(c3), avg(c4), first(c9), last(c8), first(c9) from $stb where ts >= '2018-09-16 00:00:00.000' and ts <= '2018-09-18 00:00:00.000' interval(1d) fill(linear) +if $rows != 3 then + return -1 +endi + +## previous fill +print fill(prev) +sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(prev) group by t1 limit 5 +if $rows != 25 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data18 != nchar0 then + return -1 +endi +if $data59 != 6 then + return -1 +endi +if $data69 != 6 then + return -1 +endi + +## NULL fill +print fill(NULL) +sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(value, null) group by t1 limit 5 +if $rows != 25 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data59 != 6 then + return -1 +endi +if $data69 != 6 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim new file mode 100644 index 0000000000..dd125c60f9 --- /dev/null +++ b/tests/script/general/parser/first_last.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = first_db +$tbPrefix = first_tb +$stbPrefix = first_stb +$tbNum = 10 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== first_last.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db rows 400 cache 4096 tables 4 +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c6 = $x / 128 + $c6 = $c6 * 128 + $c6 = $x - $c6 + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +$ts = $ts + 60000 +$tb = $tbPrefix . 0 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 1 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 2 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 3 +sql insert into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 4 +sql insert into $tb (ts) values ( $ts ) +$ts = $ts0 - 60000 +$tb = $tbPrefix . 0 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 1 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 2 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 3 +sql import into $tb (ts) values ( $ts ) +$tb = $tbPrefix . 4 +sql import into $tb (ts) values ( $ts ) + +print ====== test data created + +run lite/parser/first_last_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/first_last_query.sim + diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim new file mode 100644 index 0000000000..2a10e09db4 --- /dev/null +++ b/tests/script/general/parser/first_last_query.sim @@ -0,0 +1,135 @@ +sleep 3000 +sql connect + +$dbPrefix = first_db +$tbPrefix = first_tb +$stbPrefix = first_stb +$tbNum = 10 +$rowNum = 2000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== first_last_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql use $db + +##### select first/last from table +## TBASE-331 +print ====== select first/last from table +$tb = $tbPrefix . 0 +sql select first(*) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 08:59:00.000@ then + return -1 +endi +#if $data01 != NULL then +if $data01 != 0 then + return -1 +endi +#if $data02 != NULL then +if $data02 != 0 then + return -1 +endi +#if $data03 != NULL then +print data03 = $data03 +if $data03 != 0.00000 then + return -1 +endi +#if $data04 != null then +if $data04 != 0.000000000 then + return -1 +endi +#if $data05 != null then +if $data05 != 0 then + return -1 +endi +#if $data06 != null then +if $data06 != 0 then + return -1 +endi +#if $data07 != null then +if $data07 != 1 then + return -1 +endi +#if $data08 != null then +if $data08 != BINARY then + return -1 +endi +#if $data09 != null then +if $data09 != NCHAR then + return -1 +endi + +sql select last(*) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-18 01:40:00.000@ then + return -1 +endi +#if $data01 != NULL then +if $data01 != 999 then + return -1 +endi +#if $data02 != NULL then +if $data02 != 999 then + return -1 +endi +#if $data03 != NULL then +if $data03 != 999.00000 then + return -1 +endi +#if $data04 != NULL then +if $data04 != 999.000000000 then + return -1 +endi +#if $data05 != NULL then +if $data05 != 999 then + return -1 +endi +#if $data06 != NULL then +if $data06 != 103 then + return -1 +endi +#if $data07 != NULL then +if $data07 != 1 then + return -1 +endi +#if $data08 != NULL then +if $data08 != BINARY then + return -1 +endi +#if $data09 != NULL then +if $data09 != NCHAR then + return -1 +endi + +### test if first works for committed data. An 'order by ts desc' clause should be present, and queried data should come from at least 2 file blocks +$tb = $tbPrefix . 9 +sql select first(ts), first(c1) from $tb where ts < '2018-10-17 10:00:00.000' order by ts asc +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +$tb = $tbPrefix . 9 +sql select first(ts), first(c1) from $tb where ts < '2018-10-17 10:00:00.000' order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim new file mode 100644 index 0000000000..ca83fb19b2 --- /dev/null +++ b/tests/script/general/parser/groupby.sim @@ -0,0 +1,409 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt +$tbNum = 8 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== groupby.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exits $db -x step1 +step1: +sql create database if not exists $db tables 4 keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +print ===============================groupby_operation +sql select count(*),c1 from group_tb0 where c1 < 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 100 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +sql select first(ts),c1 from group_tb0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +sql select first(ts), ts, c1 from group_tb0 where c1 < 20 group by c1; +print $row +if $row != 20 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +if $data10 != $data11 then + return -1 +endi + +if $data20 != $data21 then + return -1 +endi + +if $data90 != $data91 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data12 != 1 then + return -1 +endi + +if $data92 != 9 then + return -1 +endi + +sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print $data02 +if $data02 != 0.000000000 then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +print $data04 +if $data04 != 0.0000 then + return -1 +endi + +if $data10 != 100 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +print $data12 +if $data12 != 1.000000000 then + return -1 +endi + +if $data13 != 1 then + return -1 +endi + +if $data14 != 1.0000 then + return -1 +endi + +sql_error select sum(c1), ts, c1 from group_tb0 where c1<20 group by c1; +sql_error select first(ts), ts, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select sum(c3), ts, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select sum(c3), first(ts), c2 from group_tb0 where c1 < 20 group by c1; +sql_error select first(c3), ts, c1, c2 from group_tb0 where c1 < 20 group by c1; +sql_error select first(c3), last(c3), ts, c1 from group_tb0 where c1 < 20 group by c1; + +#===========================interval=====not support====================== +sql_error select count(*), c1 from group_tb0 where c1<20 interval(1y) group by c1; +#=====tbname must be the first in the group by clause===================== +sql_error select count(*) from group_tb0 where c1 < 20 group by c1, tbname; + +#super table group by normal columns +sql select count(*), c1 from group_mt0 where c1< 20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != 800 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data10 != 800 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data90 != 800 then + return -1 +endi + +if $data91 != 9 then + return -1 +endi + +sql select first(c1), c1, ts from group_mt0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data10 != $data11 then + return -1 +endi + +if $data12 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data20 != $data21 then + return -1 +endi + +if $data22 != @70-01-01 08:01:40.002@ then + return -1 +endi + +if $data90 != $data91 then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +sql select first(c1), last(ts), first(ts), last(c1),c1,sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by c1; +if $row != 20 then + return -1 +endi + +if $data00 != $data03 then + return -1 +endi + +if $data01 != @70-01-01 08:01:49.900@ then + return -1 +endi + +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data07 != 800 then + return -1 +endi + +if $data10 != $data13 then + return -1 +endi + +if $data11 != @70-01-01 08:01:49.901@ then + return -1 +endi + +if $data12 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data17 != 800 then + return -1 +endi + +if $data90 != $data93 then + return -1 +endi + +if $data91 != @70-01-01 08:01:49.909@ then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data97 != 800 then + return -1 +endi + +if $data95 != 7200 then + return -1 +endi + +if $data94 != 9 then + return -1 +endi + +sql select first(c1), last(ts), first(ts), last(c1),sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by tbname,c1; +if $row != 160 then + return -1 +endi + +print $data00 +if $data00 != 0 then + return -1 +endi + +if $data01 != @70-01-01 08:01:49.900@ then + return -1 +endi + +print $data01 +if $data02 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != 0 then + return -1 +endi + +if $data06 != 100 then + return -1 +endi + +if $data07 != @group_tb0@ then + return -1 +endi + +if $data90 != 9 then + return -1 +endi + +if $data91 != @70-01-01 08:01:49.909@ then + return -1 +endi + +if $data92 != @70-01-01 08:01:40.009@ then + return -1 +endi + +if $data93 != 9 then + return -1 +endi + +if $data94 != 900 then + return -1 +endi + +if $data96 != 100 then + return -1 +endi + +if $data97 != @group_tb0@ then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/import.sim b/tests/script/general/parser/import.sim new file mode 100644 index 0000000000..d3b96cbf89 --- /dev/null +++ b/tests/script/general/parser/import.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = impt_db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +print ========== import.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table tb (ts timestamp, c1 int, c2 timestamp) +sql insert into tb values ('2019-05-05 11:30:00.000', 1, now) +sql insert into tb values ('2019-05-05 12:00:00.000', 1, now) +sleep 2000 +sql import into tb values ('2019-05-05 11:00:00.000', -1, now) +sleep 2000 +sql import into tb values ('2019-05-05 11:59:00.000', -1, now) +sleep 2000 +sql import into tb values ('2019-05-04 08:00:00.000', -1, now) +sleep 2000 +sql import into tb values ('2019-05-04 07:59:00.000', -1, now) +sleep 2000 + +sql select * from tb +if $rows != 6 then + return -1 +endi +if $data00 != @19-05-04 07:59:00.000@ then + return -1 +endi +if $data10 != @19-05-04 08:00:00.000@ then + return -1 +endi +if $data20 != @19-05-05 11:00:00.000@ then + return -1 +endi +if $data30 != @19-05-05 11:30:00.000@ then + return -1 +endi +if $data40 != @19-05-05 11:59:00.000@ then + return -1 +endi +if $data50 != @19-05-05 12:00:00.000@ then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +sql use $db +sql select * from tb +if $rows != 6 then + return -1 +endi +if $data00 != @19-05-04 07:59:00.000@ then + return -1 +endi +if $data10 != @19-05-04 08:00:00.000@ then + return -1 +endi +if $data20 != @19-05-05 11:00:00.000@ then + return -1 +endi +if $data30 != @19-05-05 11:30:00.000@ then + return -1 +endi +if $data40 != @19-05-05 11:59:00.000@ then + return -1 +endi +if $data50 != @19-05-05 12:00:00.000@ then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/general/parser/import_commit1.sim new file mode 100644 index 0000000000..a9935aa54e --- /dev/null +++ b/tests/script/general/parser/import_commit1.sim @@ -0,0 +1,55 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c commitTime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +#$rowNum = 166 +$rowNum = 1361 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 2048 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 60000 + +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -1) +sql select count(*) from $tb +$res = $rowNum + 1 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/general/parser/import_commit2.sim new file mode 100644 index 0000000000..d5edb89f8e --- /dev/null +++ b/tests/script/general/parser/import_commit2.sim @@ -0,0 +1,54 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c commitTime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +$rowNum = 166 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 2048 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 60000 + +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -1) +sql select count(*) from $tb +$res = $rowNum + 1 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/general/parser/import_commit3.sim new file mode 100644 index 0000000000..be915b5406 --- /dev/null +++ b/tests/script/general/parser/import_commit3.sim @@ -0,0 +1,61 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c commitTime -v 30 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ic_db +$tbPrefix = ic_tb +$stbPrefix = ic_stb +$tbNum = 1 +$rowNum = 582 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 16384 +print ====== create tables +sql use $db + +$i = 0 +$ts = $ts0 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, c1 int, c2 int, c3 int, c4 int, c5 int) +$x = 0 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x , $x , $x , $x , $x ) + $x = $x + 1 +endw +print ====== tables created + +sleep 60000 + +$ts = $ts + 1 +sql insert into $tb values ( $ts , -1, -1, -1, -1, -1) +$ts = $ts0 + $delta +$ts = $ts + 1 +sql import into $tb values ( $ts , -2, -2, -2, -2, -2) + +sleep 60000 + +sql show databases + +sql select count(*) from $tb +$res = $rowNum + 2 +if $data00 != $res then + print expected: $res + print returned: $rows + return -1 +endi + diff --git a/tests/script/general/parser/import_file.sim b/tests/script/general/parser/import_file.sim new file mode 100644 index 0000000000..2566e956b3 --- /dev/null +++ b/tests/script/general/parser/import_file.sim @@ -0,0 +1,37 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sleep 2000 + +sql drop database if exists indb + +sql create database if not exists indb + +sql use indb + +$inFileName = '~/data.csv' +$numOfRows = 10000 +#system sh/gendata.sh $inFileName $numOfRows # input file invalid +system sh/gendata.sh ~/data.csv $numOfRows + +sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2)) +print ====== create tables success, starting import data + +sql import into tbx file $inFileName + +sql select count(*) from tbx +if $rows != 1 then + return -1 +endi +if $data00 != $numOfRows then + print "expect: $numOfRows, act: $data00" + return -1 +endi + + +#system rm -f $inFileName # invalid shell +system rm -f ~/data.csv \ No newline at end of file diff --git a/tests/script/general/parser/insert_multiTbl.sim b/tests/script/general/parser/insert_multiTbl.sim new file mode 100644 index 0000000000..4e4b8b3e13 --- /dev/null +++ b/tests/script/general/parser/insert_multiTbl.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect +sleep 3000 +print ======================== dnode1 start + +sql create database mul_db +sql use mul_db +sql create table mul_st (ts timestamp, col1 int) tags (tag1 int) + +# case: insert multiple recordes for multiple table in a query +print =========== insert_multiTbl.sim case: insert multiple records for multiple table in a query +$ts = 1500000000000 +sql insert into mul_t0 using mul_st tags(0) values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_t1 using mul_st tags(1) values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_t2 using mul_st tags(2) values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_t3 using mul_st tags(3) values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32) +sql select * from mul_st +print rows = $rows +if $rows != 12 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql create table mul_b0 (ts timestamp, col1 int) +sql create table mul_b1 (ts timestamp, col1 int) +sql create table mul_b2 (ts timestamp, col1 int) +sql create table mul_b3 (ts timestamp, col1 int) + +sql insert into mul_b0 values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_b1 values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_b2 values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_b3 values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32) +sql select * from mul_b3 +print rows = $rows +if $rows != 3 then + return -1 +endi +if $data01 != 30 then + return -1 +endi + +# insert values for specified columns +sql create table mul_st1 (ts timestamp, col1 int, col2 float, col3 binary(10)) tags (tag1 int, tag2 int, tag3 binary(8)) +print =========== insert values for specified columns for multiple table in a query +$ts = 1500000000000 +sql insert into mul_t10 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(0, 'tag3-0') values ( $ts , 00, 'binary00') ( $ts + 1s, 01, 'binary01') ( $ts + 2s, 02, 'binary02') mul_t11 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(1, 'tag3-0') values ( $ts , 10, 'binary10') ( $ts + 1s, 11, 'binary11') ( $ts + 2s, 12, 'binary12') mul_t12 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(2, 'tag3-0') values ( $ts , 20, 'binary20') ( $ts + 1s, 21, 'binary21') ( $ts + 2s, 22, 'binary22') mul_t13 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(3, 'tag3-0') values ( $ts , 30, 'binary30') ( $ts + 1s, 31, 'binary31') ( $ts + 2s, 32, 'binary32') + +sql select * from mul_st1 +print rows = $rows +if $rows != 12 then + return -1 +endi +if $data02 != NULL then + print "expect: NULL, act: $data03" + return -1 +endi +if $data03 != @binary00@ then + return -1 +endi +if $data92 != NULL then + return -1 +endi +if $data93 != @binary30@ then + return -1 +endi + diff --git a/tests/script/general/parser/insert_tb.sim b/tests/script/general/parser/insert_tb.sim new file mode 100644 index 0000000000..f7e2980707 --- /dev/null +++ b/tests/script/general/parser/insert_tb.sim @@ -0,0 +1,235 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(20), col6 bool, col7 smallint, col8 tinyint, col9 nchar(10)) tags (tag1 int) + +# case: insert multiple records in a query +print =========== create_tb.sim case: insert multiple records in a query +$ts = 1500000000000 +$col1 = 1 +$col2 = 1 +$col3 = 1.1e3 +$col4 = 1.1e3 +$col5 = 'Binary' +$col6 = true +$col7 = 1 +$col8 = 1 +$col9 = 'Nchar' +$tag1 = 1 +sql reset query cache +sql create table $tb using $mt tags( $tag1 ) +sql insert into $tb values ( $ts , $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) ( $ts + 1000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) +sql select * from $tb order by ts desc +print rows = $rows +if $rows != 2 then + return -1 +endi +if $data01 != $col1 then + return -1 +endi +#sql drop table $tb + +# insert values for specified columns +$col1 = 2 +$col3 = 3 +$col5 = 5 +sql create table $tb using $mt tags( $tag1 ) +sql insert into $tb ( ts, col1, col3, col5) values ( $ts + 2000a, $col1 , $col3 , $col5 ) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != $col1 then + return -1 +endi +print data03 = $data03 +if $data03 != 3.00000 then + return -1 +endi +if $data05 != $col5 then + return -1 +endi + +sql insert into $tb (ts, col1, col2, col3, col4, col5, col6, col7, col8, col9) values ( $ts + 3000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) ( $ts + 4000a, $col1 , $col2 , $col3 , $col4 , $col5 , $col6 , $col7 , $col8 , $col9 ) +sql select * from $tb order by ts desc +print rows = $rows +if $rows != 5 then + return -1 +endi + +# case: insert records from .csv files +# manually test +#sql insert into $tb file parser/parser_test_data.csv +#sql select * from $tb +#if $rows != 10 then +# return -1 +#endi + +sql drop table $tb +sql create table tb1 (ts timestamp, c1 int) +sql create table tb2 (ts timestamp, c1 int) +sql insert into tb1 values(now, 1) tb2 values (now, 2) +sql select count(*) from tb1 +if $rows != 1 then + return -1 +endi +sql select count(*) from tb2 +if $rows != 1 then + return -1 +endi + +sql drop database $db +sleep 1000 +sql create database $db +sql use $db +sql create table stb1 (ts timestamp, c1 int) tags(t1 int) +sql create table stb2 (ts timestamp, c1 double, c2 binary(10)) tags(t1 binary(10)) +sql create table tb1 using stb1 tags(1) +sql create table tb2 using stb2 tags('tb2') +sql insert into tb1 (ts, c1) values (now-1s, 1) (now, 2) tb2 (ts, c1) values (now-2s, 1) (now-1s, 2) (now, 3) +sql select * from tb1 order by ts asc +if $rows != 2 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +sql select * from tb2 order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 3.000000000 then + return -1 +endi +if $data11 != 2.000000000 then + return -1 +endi +if $data21 != 1.000000000 then + return -1 +endi + +sql drop database $db +sleep 1000 +sql create database $db +sql use $db +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 nchar(10), c6 binary(20)) tags(t1 int, t2 bigint, t3 double, t4 float, t5 nchar(10)) +sql create table tb0 using stb tags(0, 0, 0, 0, '涛æ€') +sql create table tb1 using stb tags('1', 1, 1, 1, '涛æ€') +sql create table tb2 using stb tags(2, '2', 2, 2, '涛æ€') +sql create table tb3 using stb tags(3, 3, '3', 3, '涛æ€') +sql create table tb4 using stb tags(4, 4, 4, '4', '涛æ€') +sql insert into tb0 values ('2018-09-17 09:00:00.000', 1, 1, 1, 1, '涛æ€nchar', 'none quoted') +sql insert into tb1 values ('2018-09-17 09:00:00.000', '1', 1, 1, 1, '涛æ€nchar', 'quoted int') +sql insert into tb2 values ('2018-09-17 09:00:00.000', 1, '1', 1, 1, '涛æ€nchar', 'quoted bigint') +sql insert into tb3 values ('2018-09-17 09:00:00.000', 1, 1, '1', 1, '涛æ€nchar', 'quoted float') +sql insert into tb4 values ('2018-09-17 09:00:00.000', 1, 1, 1, '1', '涛æ€nchar', 'quoted double') +sql select * from stb +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data30 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 涛æ€nchar then + return -1 +endi +if $data06 != @none quoted@ then + return -1 +endi +if $data13 != 1.00000 then + return -1 +endi +if $data14 != 1.000000000 then + return -1 +endi +if $data15 != 涛æ€nchar then + return -1 +endi +if $data16 != @quoted int@ then + return -1 +endi +if $data25 != 涛æ€nchar then + return -1 +endi +if $data26 != @quoted bigint@ then + return -1 +endi +if $data35 != 涛æ€nchar then + return -1 +endi +if $data36 != @quoted float@ then + return -1 +endi +if $data45 != 涛æ€nchar then + return -1 +endi +if $data46 != @quoted double@ then + return -1 +endi + +# case: support null char of the binary field [TBASE-660] +sql create table nullb (ts timestamp, c1 binary(20), c2 binary(20), c3 float) +sql insert into nullb values ('2018-09-17 09:00:00.000', '', '', 3.746) +sql select * from nullb +if $rows != 1 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + + diff --git a/tests/script/general/parser/interp.sim b/tests/script/general/parser/interp.sim new file mode 100644 index 0000000000..2d3bc2ac87 --- /dev/null +++ b/tests/script/general/parser/interp.sim @@ -0,0 +1,67 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = intp_db +$tbPrefix = intp_tb +$stbPrefix = intp_stb +$tbNum = 4 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== interp.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run lite/parser/interp_test.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/interp_test.sim diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim new file mode 100644 index 0000000000..03e6997321 --- /dev/null +++ b/tests/script/general/parser/interp_test.sim @@ -0,0 +1,834 @@ +sleep 3000 +sql connect + +$dbPrefix = intp_db +$tbPrefix = intp_tb +$stbPrefix = intp_stb +$tbNum = 4 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== intp_test.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ====== use db +sql use $db + +##### select interp from table +print ====== select intp from table +$tb = $tbPrefix . 0 + ## interp(*) from tb + sql select interp(*) from $tb where ts = $ts0 + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + + ## interp + limit offset + sql select interp(*) from $tb where ts = $ts0 limit 5 offset 1 + if $rows != 0 then + return -1 + endi + + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + + ## intp + aggregation functions + #$t = $ts0 + $delta + #$t = $t + $delta + #sql_error select interp(ts), max(c1), min(c2), count(c3), sum(c4), avg(c5), stddev(c6), first(c7), last(c8), interp(c9) from $tb where ts = $t + + ### illegal queries on a table + sql_error select interp(ts), c1 from $tb where ts = $ts0 + sql_error select interp(ts) from $tb where ts >= $ts0 + sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(null) + + ### interp from tb + fill + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t + if $rows != 0 then + return -1 + endi + + ## fill(none) + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) + if $rows != 0 then + return -1 + endi + $t = $tsu + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) + if $rows != 0 then + return -1 + endi + + ## fill(null) + $t = $tsu - 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, NULL) order by ts asc + if $rows != 1 then + return -1 + endi + if $data00 != @18-11-25 19:29:59.000@ then + return -1 + endi + if $data01 != null then + return -1 + endi + if $data02 != null then + return -1 + endi + if $data03 != null then + return -1 + endi + if $data04 != null then + return -1 + endi + if $data05 != null then + return -1 + endi + if $data06 != null then + return -1 + endi + if $data07 != null then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + + $t = $tsu + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) + if $rows != 0 then + return -1 + endi + + ## fill(prev) + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) + if $rows != 1 then + return -1 + endi + + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(prev) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + + $t = $ts0 - 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) + if $rows != 0 then + return -1 + endi + + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(prev) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != null then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi +# if $data04 != NULL then +# return -1 +# endi + + $t = $tsu + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) + if $rows != 0 then + return -1 + endi + + ## fill(linear) + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + print $data03 + if $data03 != 0.00167 then + return -1 + endi + if $data04 != 0.001666667 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != null then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + # columns contain NULL values + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(linear) + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != null then + return -1 + endi + if $data03 != 0.00167 then + return -1 + endi + if $data04 != null then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != null then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + # columns contain NULL values + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != null then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != null then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + + $t = $ts0 - 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) + if $rows != 0 then + return -1 + endi + + $t = $tsu + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) + if $rows != 0 then + return -1 + endi + +## fill(value) + $t = $ts0 + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != -2 then + return -1 + endi + if $data02 != -2 then + return -1 + endi + if $data03 != -2.00000 then + return -1 + endi + if $data04 != -2.000000000 then + return -1 + endi + if $data05 != -2 then + return -1 + endi + if $data06 != -2 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(value, -1, -2, -3) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + # table has null columns + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(value, -1, -2, -3) + if $rows != 1 then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != null then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != null then + return -1 + endi + + $t = $ts0 - 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) + if $rows != 0 then + return -1 + endi + + $t = $tsu + 1000 + sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) + if $rows != 0 then + return -1 + endi + +##### select interp from stable + ## interp(*) from stb + sql select interp(*) from $stb where ts = $ts0 + if $rows != 1 then + return -1 + endi + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t + if $rows != 0 then + return -1 + endi + ## interp(*) from stb + group by + sql select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc + print ====== select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 + if $rows != $tbNum then + return -1 + endi + if $data00 != @18-09-17 09:00:00.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data08 != intp_tb0 then + return -1 + endi + if $data22 != null then + return -1 + endi + if $data24 != null then + return -1 + endi + if $data28 != intp_tb2 then + return -1 + endi + + ## interp(*) from stb + group by + limit offset + sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 + if $rows != 0 then + return -1 + endi + sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 offset 1 + + ## interp(*) from stb + group by + fill(none) + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t fill(none) group by tbname + if $rows != 0 then + return -1 + endi + + sql select interp(*) from $stb where ts = $ts0 fill(none) group by tbname + if $rows != 4 then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data21 != 0 then + return -1 + endi + if $data22 != null then + return -1 + endi + if $data24 != null then + return -1 + endi + + ## interp(*) from stb + group by + fill(none) + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t fill(null) group by tbname +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != null then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data23 != null then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data16 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data09 != null then + return -1 +endi + +sql select interp(*) from $stb where ts = $ts0 fill(null) group by tbname +print $rows + +if $rows != 4 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != 0 then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data24 != null then + return -1 +endi + + ## interp(*) from stb + group by + fill(prev) + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t fill(prev) group by tbname + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 + if $rows != $tbNum then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00000 then + return -1 + endi + if $data04 != 0.000000000 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != binary0 then + return -1 + endi + if $data09 != nchar0 then + return -1 + endi + if $data20 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data21 != 0 then + return -1 + endi + if $data22 != null then + return -1 + endi + if $data23 != 0.00000 then + return -1 + endi + if $data24 != null then + return -1 + endi + if $data25 != 0 then + return -1 + endi + if $data26 != 0 then + return -1 + endi + if $data27 != 1 then + return -1 + endi + if $data28 != binary0 then + return -1 + endi + if $data29 != nchar0 then + return -1 + endi + + ## interp(*) from stb + group by + fill(linear) + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t fill(linear) group by tbname + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 + if $rows != $tbNum then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != 0 then + return -1 + endi + if $data02 != 0 then + return -1 + endi + if $data03 != 0.00167 then + return -1 + endi + if $data04 != 0.001666667 then + return -1 + endi + if $data05 != 0 then + return -1 + endi + if $data06 != 0 then + return -1 + endi + if $data07 != null then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + if $data20 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data21 != 0 then + return -1 + endi + if $data22 != null then + return -1 + endi + if $data23 != 0.00167 then + return -1 + endi + if $data24 != null then + return -1 + endi + if $data25 != 0 then + return -1 + endi + if $data26 != 0 then + return -1 + endi + if $data27 != null then + return -1 + endi + if $data28 != null then + return -1 + endi + if $data29 != null then + return -1 + endi + + ## interp(*) from stb + group by + fill(value) + $t = $ts0 + 1000 + sql select interp(*) from $stb where ts = $t fill(value, -1, -2) group by tbname + print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 + print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 + if $rows != $tbNum then + return -1 + endi + if $data00 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data01 != -2 then + return -1 + endi + if $data02 != -2 then + return -1 + endi + if $data03 != -2.00000 then + return -1 + endi + if $data04 != -2.000000000 then + return -1 + endi + if $data05 != -2 then + return -1 + endi + if $data06 != -2 then + return -1 + endi + if $data07 != 1 then + return -1 + endi + if $data08 != null then + return -1 + endi + if $data09 != null then + return -1 + endi + if $data20 != @18-09-17 09:00:01.000@ then + return -1 + endi + if $data21 != -2 then + return -1 + endi + if $data22 != -2 then + return -1 + endi + if $data23 != -2.00000 then + return -1 + endi + if $data24 != -2.000000000 then + return -1 + endi + if $data25 != -2 then + return -1 + endi + if $data26 != -2 then + return -1 + endi + if $data27 != 1 then + return -1 + endi + if $data28 != null then + return -1 + endi + if $data29 != null then + return -1 + endi diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim new file mode 100644 index 0000000000..b9b35e0cd3 --- /dev/null +++ b/tests/script/general/parser/join.sim @@ -0,0 +1,446 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c debugFlag -v 135 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +$dbPrefix = join_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 2 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum + +print =============== join.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exits $db -x step1 +step1: +sql create database if not exists $db tables 4 keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$tstart = 100000 +$mt = $mtPrefix . 1 . $i +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix = join_1_tb + +while $i < $tbNum + $tb = $tbPrefix . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb using $mt tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = join_db +$tbPrefix = join_tb +$mtPrefix = join_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +#single table join sql + +# select duplicate columns +sql select $ts1 , $ts2 from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star1 +sql select join_tb1.*, join_tb0.ts from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 + +$val = $rowNum +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 0; + +$val = 0 +if $rows != $val then + return -1 +endi + +# select star2 +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 limit 0; + +$val = 0 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts = 100000 limit 10; + +$val = 1 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false limit 10; + +$val = 10 +if $rows != $val then + return -1 +endi + +#select + where condition +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false limit 10 offset 1; +print $rows +if $rows != 9 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.100@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.200@ then + return -1 +endi + +if $data07 != 0 then + return -1 +endi + +#select + where condition ======reverse query +sql select join_tb1.*, join_tb0.* from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true order by join_tb0.ts asc limit 1; + +$val = 1 +if $rows != $val then + return -1 +endi + +$val = @70-01-01 08:01:40.001@ +print $data00, $data01 + +if $data00 != $val then + return -1 +endi + +print 1 +#select + where condition + interval query +sql select count(join_tb1.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = true interval(10a) order by join_tb0.ts desc; + +$val = 100 +if $rows != $val then + return -1 +endi + +print 2 +#===========================aggregation=================================== +#select + where condition +sql select count(join_tb1.*), count(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false; + +$val = 10 +if $data00 != $val then + return -1 +endi + +if $data01 != $val then + return -1 +endi + +print 3 +#agg + where condition +sql select count(join_tb1.c3), count(join_tb0.ts) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts <= 100002 and join_tb0.c7 = true; + +$val = 2 +if $data00 != $val then + return -1 +endi + +if $data01 != $val then + return -1 +endi + +print 4 +#agg + where condition +sql select count(join_tb1.c3), count(join_tb0.ts), sum(join_tb0.c1), first(join_tb0.c7), last(join_tb1.c3), first(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts <= 100002 and join_tb0.c7 = true; + +$val = 2 +if $data00 != $val then + return -1 +endi + +if $data01 != $val then + return -1 +endi + +if $data02 != 3 then + return -1 +endi + +if $data03 != 1 then + return -1 +endi + +if $data04 != 2 then + return -1 +endi + +print =============== join.sim -- error sql + +sql_error select count(join_tb1.c3), count(join_tb0.ts), sum(join_tb0.c1), first(join_tb0.c7), last(join_tb1.c3) from $tb1 , $tb2 where join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select count(join_tb1.c3), last(join_tb1.c3) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts or join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select count(join_tb3.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select first(join_tb1.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 or join_tb0.c7 = true; +sql_error select join_tb3.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.c7 = join_tb0.c1; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts > join_tb0.ts; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts <> join_tb0.ts; +sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts != join_tb0.ts and join_tb1.ts > 100000; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts and join_tb1.ts >= 100000; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by ts; +sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by join_tb1.c7; + + +print ==================================super table join ============================== +# select duplicate columns +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1; + +$val = $rowNum + $rowNum +print $val +print $rows +if $rows != $val then + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.ts = 100000; + +$val = 2 +if $rows != $val then + return -1 +endi + +sql select join_mt1.* from join_mt1 + +print $rows + +$val = 2000 +if $rows != $val then + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1; + +$val = 2000 +if $rows != $val then + return -1 +endi + +sql select join_mt0.* from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99; + +$val = 20 +if $rows != $val then + return -1 +endi + +sql select count(*) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99; + +$val = 20 +if $data00 != $val then + return -1 +endi + +sql select count(*) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99 and join_mt1.ts=100999; + +$val = 2 +if $data00 != $val then + return -1 +endi + +# agg +sql select sum(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.ts = join_mt1.ts and join_mt0.t1=join_mt1.t1 and join_mt0.c2=99 and join_mt1.ts=100999; + +$val = 198 +if $data00 != $val then + return -1 +endi + +# first/last +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts asc; + +$val = 100 +if $rows != $val then + return -1 +endi + +$val = 10 +if $data01 != $val then + return -1 +endi + +$val = 45.000000000 +print $data02 +if $data02 != $val then + return -1 +endi + +$val = 0 +if $data03 != 0 then + return -1 +endi + +# order by first/last +sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts desc; + +$val = 100 +if $rows != $val then + return -1 +endi + +#====================group by========================================= + + + + +#======================limit offset=================================== +# tag values not int +sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2; + +# tag type not identical +sql_error select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts; + +# table/super table join +sql_error select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts + +# multi-condition + + +# self join +sql_error select count(join_mt0.c1), count(join_mt0.c2) from join_mt0, join_mt0 where join_mt0.ts=join_mt0.ts and join_mt0.t1=join_mt0.t1; + +# missing ts equals +sql_error select sum(join_mt1.c2) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1; + +# missing tag equals +sql_error select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts; + +# tag values are identical error +sql create table m1(ts timestamp, k int) tags(a int); +sql create table m2(ts timestamp, k int) tags(a int); + +sql create table tm1 using m1 tags(1); +sql create table tm2 using m1 tags(1); + +sql insert into tm1 using m1 tags(1) values(1000000, 1)(2000000, 2); +sql insert into tm2 using m1 tags(1) values(1000000, 1)(2000000, 2); + +sql insert into um1 using m2 tags(1) values(1000001, 10)(2000000, 20); +sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20); + +sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts; diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/general/parser/join_multivnode.sim new file mode 100644 index 0000000000..46f38f9ce0 --- /dev/null +++ b/tests/script/general/parser/join_multivnode.sim @@ -0,0 +1,130 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 1000 + +$dbPrefix = join_m_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 3 +$rowNum = 1000 +$totalNum = $tbNum * $rowNum + +print =============== join_multivnode.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exits $db -x step1 +step1: +sql create database if not exists $db tables 4 keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$tstart = 100000 +$mt = $mtPrefix . 1 . $i +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix = join_1_tb + +while $i < $tbNum + $tb = $tbPrefix . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb using $mt tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +print ===============multivnode projection join.sim + +sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; + +print $row +if $row != 3000 then + return -1 +endi + +print ======= second tags join + +sql create table m1(ts timestamp, k int) tags(a binary(12), b int); +sql create table m2(ts timestamp, k int) tags(a binary(12), b int); + +sql insert into tm1 using m1 tags('tm1', 1) values(10000000, 1) tm2 using m2 tags('tm2', 1) values(10000000, 99); + +sql select * from m1,m2 where m1.ts=m2.ts and m1.b=m2.b; +if $row != 1 then + return -1 +endi + +sql select join_mt0.ts, join_mt1.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 + +sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 + +sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbname from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1 limit 1 \ No newline at end of file diff --git a/tests/script/general/parser/lastrow.sim b/tests/script/general/parser/lastrow.sim new file mode 100644 index 0000000000..c76c71b62e --- /dev/null +++ b/tests/script/general/parser/lastrow.sim @@ -0,0 +1,70 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lr_db +$tbPrefix = lr_tb +$stbPrefix = lr_stb +$tbNum = 8 +$rowNum = 60 * 24 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== lastrow.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db tables 4 +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = $tbNum +while $i > 0 + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + $i = $i - 1 +endw + +$ts = $ts0 +$i = 1 +while $i <= $tbNum + $x = 0 + $tb = $tbPrefix . $i + while $x < $rowNum + $ts = $ts + $delta + $c6 = $x / 128 + $c6 = $c6 * 128 + $c6 = $x - $c6 + $c3 = NULL + $xr = $x / 10 + $xr = $xr * 10 + $xr = $x - $xr + if $xr = 0 then + $c3 = $x + endi + sql insert into $tb values ( $ts , $x , NULL , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ====== test data created + +run lite/parser/lastrow_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/lastrow_query.sim diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/general/parser/lastrow_query.sim new file mode 100644 index 0000000000..3ff0426dcd --- /dev/null +++ b/tests/script/general/parser/lastrow_query.sim @@ -0,0 +1,51 @@ +sleep 3000 +sql connect + +$dbPrefix = lr_db +$tbPrefix = lr_tb +$stbPrefix = lr_stb +$tbNum = 8 +$rowNum = 60 * 24 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 60000 +print ========== lastrow_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql use $db + +##### select lastrow from STable with two vnodes, timestamp decreases from tables in vnode0 to tables in vnode1 +sql select last_row(*) from $stb +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-25 09:00:00.000@ then + return -1 +endi +if $data01 != 1439 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != 1439.00000 then + return -1 +endi +if $data04 != 1439.000000000 then + return -1 +endi +if $data06 != 31 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != BINARY then + return -1 +endi +if $data09 != NCHAR then + return -1 +endi + diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim new file mode 100644 index 0000000000..4ca348dbd6 --- /dev/null +++ b/tests/script/general/parser/limit.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run lite/parser/limit_tb.sim +run lite/parser/limit_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/limit_tb.sim +run lite/parser/limit_stb.sim diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim new file mode 100644 index 0000000000..bdb5b90983 --- /dev/null +++ b/tests/script/general/parser/limit1.sim @@ -0,0 +1,69 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run lite/parser/limit1_tb.sim +run lite/parser/limit1_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/limit1_tb.sim +run lite/parser/limit1_stb.sim diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim new file mode 100644 index 0000000000..b9ba90ef50 --- /dev/null +++ b/tests/script/general/parser/limit1_stb.sim @@ -0,0 +1,693 @@ +sleep 3000 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ====== use db +sql use $db + +#### select from supertable + +### select from stb + limit offset +sql select * from $stb limit 5 +if $rows != 5 then + return -1 +endi +sql select * from $stb limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +$val = $totalNum - 1 +sql select * from $stb limit $totalNum offset 1 +if $rows != $val then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +##TBASE-352 +$offset = $tbNum * $rowNum +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset / 2 +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 2 then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != 9 then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != 0.00000 then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != 0 then + return -1 +endi +if $data16 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != binary0 then + return -1 +endi +if $data19 != nchar0 then + return -1 +endi + +### offset >= rowsInFileBlock +##TBASE-352 +$limit = $totalNum / 2 +$offset = $totalNum +sql select * from $stb limit $limit offset $offset +if $rows != 0 then + return -1 +endi +$offset = $offset - 1 +sql select * from $stb limit $limit offset $offset +if $rows != 1 then + return -1 +endi +$limit = $totalNum / 2 +$offset = $totalNum / 2 +$offset = $offset - 1 +sql select * from $stb limit $limit offset $offset +if $rows != $limit then + return -1 +endi +$offset = $totalNum / 2 +$offset = $offset + 1 +sql select * from $stb limit $limit offset $offset +$val = $limit - 1 +if $rows != $val then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1; +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +### select from supertable + where + limit offset +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 7 then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data41 != 4 then + return -1 +endi + +$offset = $totalNum / 2 +sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data34 != null then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary2 then + return -1 +endi +if $data39 != nchar3 then + return -1 +endi + +$limit = $totalNum / 2 +sql select * from $stb where ts >= $ts0 and ts <= $tsu limit $limit offset 1 +if $rows != $limit then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi +if $data34 != 4.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary3 then + return -1 +endi +if $data39 != nchar4 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu limit 1 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +$val = 45 * $rowNum +if $data03 != $val then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary9 then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5.000000000 then + return -1 +endi +$val = 5 * $rowNum +$val = $val / 10 +if $data03 != $val then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary5 then + return -1 +endi +if $data07 != nchar5 then + return -1 +endi + +$limit = $totalNum +$offset = $totalNum +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 limit $limit offset $offset +if $rows != 0 then + return -1 +endi + +## TBASE-353 +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 1 +if $rows != 0 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi +if $data09 != 2 then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data14 != $val then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 1 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data42 != 4.500000000 then + return -1 +endi +if $data33 != 0 then + return -1 +endi +if $data43 != 0 then + return -1 +endi +if $data59 != 7 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 1 +if $rows != 0 then + return -1 +endi + +$limit = $totalNum / 2 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != null then + return -1 +endi +if $data12 != 4.500000000 then + return -1 +endi +if $data23 != 0 then + return -1 +endi +if $data09 != 7 then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data14 != $val then + return -1 +endi +if $data19 != 6 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 1 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != 4.500000000 then + return -1 +endi +if $data33 != $rowNum then + return -1 +endi +$val = 9 * $rowNum +$val = $val / 2 +if $data44 != $val then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +### supertable aggregation + where + interval + limit offset +## TBASE-355 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data15 != 12 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +### [TBASE-361] +$offset = $rowNum / 2 +$offset = $offset + 1 +sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset +$val = $rowNum - $offset +if $rows != $val then + return -1 +endi +if $data00 != @18-10-22 02:30:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data30 != @18-10-22 03:00:00.000@ then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data42 != 5 then + return -1 +endi +if $data53 != 6.000000000 then + return -1 +endi +if $data54 != 3 then + return -1 +endi +if $data55 != 36 then + return -1 +endi + +## supertable aggregation + where + interval + group by order by tag + limit offset +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data22 != 5 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data33 != 6.000000000 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data44 != 5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data58 != nchar6 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 1 +if $rows != 6 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data28 != nchar6 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data46 != 1 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar5 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data23 != 5.000000000 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data48 != nchar5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data59 != 2 then + return -1 +endi diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim new file mode 100644 index 0000000000..a9484d10db --- /dev/null +++ b/tests/script/general/parser/limit1_tb.sim @@ -0,0 +1,1154 @@ +sleep 3000 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +##### select from table +print ====== select from table with limit offset +$tb = $tbPrefix . 0 +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data41 != 0 then + return -1 +endi + +$offset = $rowNum - 1 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi + +## TBASE-329 +sql select * from $tb where c1 < 9 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 7 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 5 then + return -1 +endi + +sql select * from $tb where c1 < 0 order by ts desc limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data11 != 7 then + return -1 +endi + + +sql_error select * from $tb limit +sql_error select * from $tb offset +sql_error select * from $tb offset 1 +sql_error select * from $tb offset 1 limit 5 +sql_error select * from $tb offset 1 limit -1 + +#### aggregation function + limit offset +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +### aggregation function + limit offset (non-interval case) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu and c1 < 9 and c2 < 8 and c3 >0 and c4 <= 7 and c5 <7 limit 5 offset 0 +if $rows != 1 then + return -1 +endi + +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 offset 0 +if $rows != 0 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +$val = 45 * $rowNum +$val = $val / 10 +if $data00 != $val then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 2.872281323 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != $rowNum then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary9 then + return -1 +endi +if $data08 != nchar9 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1>1 and c2<9 and c3>2 and c4<8 and c5>4 and c6<6 limit 1 offset 0 +if $rows != 1 then + return -1 +endi +$val = $rowNum / 10 +$val = $val * 5 +if $data00 != $val then + return -1 +endi +if $data01 != 5.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +$val = $rowNum / 10 +if $data05 != $val then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary5 then + return -1 +endi +if $data08 != nchar5 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +$val = $rowNum - 1 +$val = $val * 600000.000000000 +$val = $data00 - $val +if $val != 0 then + return -1 +endi +if $data01 != 9.000000000 then + return -1 +endi +if $data02 != 9.000000000 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9.000000000 then + return -1 +endi +if $data06 != 9.000000000 then + return -1 +endi +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +$val = $tsu + $delta +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $val limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.500000000 then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data03 != 4.500000000 then + return -1 +endi +if $data04 != 4.500000000 then + return -1 +endi +if $data05 != 4.500000000 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $val limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +## TBASE-354 +sql select top(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 12:10:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-09-17 13:50:00.000@ then + return -1 +endi +if $data11 != 9 then + return -1 +endi +if $data20 != @18-09-17 15:30:00.000@ then + return -1 +endi +if $data21 != 9 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select bottom(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:40:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 12:20:00.000@ then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data20 != @18-09-17 14:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select diff(c1) from $tb +$res = $rowNum - 1 +if $rows != $res then + return -1 +endi + +sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data11 != 1 then + return -1 +endi +$limit = $rowNum / 2 +$offset = $limit - 1 +sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset +if $rows != $limit then + return -1 +endi +$limit = $rowNum / 2 +$offset = $limit + 1 +$val = $limit - 2 +sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset +if $rows != $val then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data81 != -9 then + return -1 +endi + +### aggregation + limit offset (with interval) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +## TBASE-334 +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data11 != 8 then + return -1 +endi +if $data14 != 8.000000000 then + return -1 +endi +if $data21 != null then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 0 then + return -1 +endi + +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 21 then + return -1 +endi +if $data31 != 10 then + return -1 +endi +if $data41 != 9 then + return -1 +endi +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 12 then + return -1 +endi +if $data11 != 21 then + return -1 +endi +if $data21 != 10 then + return -1 +endi +if $data31 != 9 then + return -1 +endi +if $data41 != 18 then + return -1 +endi + +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 4.000000000 then + return -1 +endi +if $data11 != 7.000000000 then + return -1 +endi +if $data21 != 3.333333333 then + return -1 +endi + +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 0 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 0.816496581 then + return -1 +endi +if $data10 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data21 != 4.027681991 then + return -1 +endi + +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) +if $rows != 3704 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 2 then + return -1 +endi +if $data41 != 3 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.499549955 then + return -1 +endi +if $data02 != 4.499549955 then + return -1 +endi +if $data05 != 4.499549955 then + return -1 +endi + +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + + +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 1.00000 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 3.00000 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data29 != nchar8 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data08 != binary3 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 8 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 8.000000000 then + return -1 +endi +if $data22 != 9 then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data24 != 9.00000 then + return -1 +endi +if $data25 != 1.000000000 then + return -1 +endi +if $data26 != 9 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != binary9 then + return -1 +endi +if $data29 != nchar1 then + return -1 +endi + +### order by ts + limit offset + +sql select * from $tb order by ts asc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data34 != 3.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary2 then + return -1 +endi +if $data39 != nchar3 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi +if $data34 != 4.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary3 then + return -1 +endi +if $data39 != nchar4 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 8 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi + +sql select * from $tb where c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data10 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi + +$offset = $rowNum / 10 +sql select * from $tb where c1 < 3 and c1 > 1 order by ts asc limit 3 offset $offset +if $rows != 0 then + return -1 +endi + +$offset = $rowNum / 10 +$offset = $offset * 3 +$offset = $offset - 1 +sql select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 18:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-11-25 19:20:00.000@ then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-11-25 19:10:00.000@ then + return -1 +endi +if $data23 != 7.00000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary7 then + return -1 +endi +if $data39 != nchar6 then + return -1 +endi +if $data40 != @18-11-25 18:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-11-25 19:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-11-25 19:10:00.000@ then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != @18-11-25 19:00:00.000@ then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi +if $data34 != 5.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data39 != nchar5 then + return -1 +endi +if $data40 != @18-11-25 18:40:00.000@ then + return -1 +endi + +$offset = $rowNum +$offset = $offset - 2 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data12 != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 order by ts desc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-11-25 18:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data10 != @18-11-25 18:40:00.000@ then + return -1 +endi +if $data20 != @18-11-25 18:30:00.000@ then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi + +$offset = $rowNum / 10 +sql select * from $tb where c1 < 8 and c1 > 6 order by ts desc limit 3 offset $offset +if $rows != 0 then + return -1 +endi + +$limit = $rowNum / 10 +$limit = $limit * 3 +$offset = $limit - 1 +sql select * from $tb where c1 < 8 and c1 > 4 order by ts desc limit $limit offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim new file mode 100644 index 0000000000..6e108226a5 --- /dev/null +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -0,0 +1,69 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lm1_db +$tbPrefix = lm1_tb +$stbPrefix = lm1_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit1.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db tblocks 100 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run lite/parser/limit1_tb.sim +run lite/parser/limit1_stb.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/limit1_tb.sim +run lite/parser/limit1_stb.sim diff --git a/tests/script/general/parser/limit2.sim b/tests/script/general/parser/limit2.sim new file mode 100644 index 0000000000..4374ac9be2 --- /dev/null +++ b/tests/script/general/parser/limit2.sim @@ -0,0 +1,76 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +#run lite/parser/limit2_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/limit2_query.sim diff --git a/tests/script/general/parser/limit2_query.sim b/tests/script/general/parser/limit2_query.sim new file mode 100644 index 0000000000..d5b4d3e5ff --- /dev/null +++ b/tests/script/general/parser/limit2_query.sim @@ -0,0 +1,325 @@ +sleep 3000 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tb = $tbPrefix . 0 +print ====== use db +sql use $db + +##### aggregation on stb with 6 tags + where + group by + limit offset +$val1 = 1 +$val2 = $tbNum - 1 +sql select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +$val = $tbNum - 3 +if $rows != $val then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != tb2 then + return -1 +endi +if $data03 != tb2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi +if $data05 != 2 then + return -1 +endi + +sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 0 +if $rows != 2 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != tb4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data11 != tb3 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1 +if $rows != 0 then + return -1 +endi +## TBASE-348 +sql_error select count(*) from $stb where t1 like 1 + +##### aggregation on tb + where + fill + limit offset +sql select max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit 10 offset 1 +if $rows != 10 then + return -1 +endi +if $data00 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data90 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data91 != 5 then + return -1 +endi + +$tb5 = $tbPrefix . 5 +sql select max(c1), min(c2) from $tb5 where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4) limit 10 offset 1 +if $rows != 10 then + return -1 +endi +if $data00 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data90 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data91 != 5 then + return -1 +endi +if $data92 != -2 then + return -1 +endi + +### [TBASE-350] +## tb + interval + fill(value) + limit offset +$tb = $tbPrefix . 0 +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != $limit then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +# tb + interval + fill(linear) + limit offset +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) limit $limit offset $offset +if $rows != $limit then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data13 != 0.500000000 then + return -1 +endi +if $data35 != 0.000000000 then + return -1 +endi +if $data46 != 0.000000000 then + return -1 +endi +if $data47 != 1 then + return -1 +endi +if $data57 != null then + return -1 +endi +if $data68 != binary3 then + return -1 +endi +if $data79 != null then + return -1 +endi + +## tb + interval + fill(prev) + limit offset +$limit = $rowNum +$offset = $limit / 2 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) limit $limit offset $offset +if $rows != $limit then + return -1 +endi + + +$limit = $rowNum +$offset = $limit / 2 +$offset = $offset + 10 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != $limit then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != 0.000000000 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary5 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data19 != null then + return -1 +endi +if $data16 != -2.000000000 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data11 != -1 then + return -1 +endi + +$limit = $rowNum +$offset = $limit * 2 +$offset = $offset - 11 +sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +if $rows != 10 then + return -1 +endi +if $data01 != -1 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data11 != 5 then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data15 != 0.000000000 then + return -1 +endi +if $data16 != 0.000000000 then + return -1 +endi +if $data18 != binary5 then + return -1 +endi +if $data19 != nchar5 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data38 != null then + return -1 +endi +if $data49 != null then + return -1 +endi + +### [TBASE-350] +## stb + interval + fill + group by + limit offset +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10 +if $rows != 20 then + return -1 +endi + +$limit = 5 +$offset = $rowNum * 2 +$offset = $offset - 2 +sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 order by t1 limit $limit offset $offset +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-11-25 19:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data12 != 9 then + return -1 +endi +if $data23 != 9.000000000 then + return -1 +endi +if $data34 != 9.000000000 then + return -1 +endi +if $data45 != 1 then + return -1 +endi +if $data56 != binary9 then + return -1 +endi +if $data68 != 6 then + return -1 +endi +if $data72 != -2 then + return -1 +endi +if $data84 != -2.000000000 then + return -1 +endi +if $data98 != 9 then + return -1 +endi diff --git a/tests/script/general/parser/limit2_tblocks100.sim b/tests/script/general/parser/limit2_tblocks100.sim new file mode 100644 index 0000000000..061d7225b1 --- /dev/null +++ b/tests/script/general/parser/limit2_tblocks100.sim @@ -0,0 +1,76 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = lm2_db +$tbPrefix = lm2_tb +$stbPrefix = lm2_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== limit2.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db tblocks 100 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +#run lite/parser/limit2_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/limit2_query.sim diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim new file mode 100644 index 0000000000..3e3c75ddac --- /dev/null +++ b/tests/script/general/parser/limit_stb.sim @@ -0,0 +1,1235 @@ +sleep 3000 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit_stb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +##### select from supertable + +# illegal operations +#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 + +### select from stb + limit offset +sql select * from $stb limit 5 +if $rows != 5 then + return -1 +endi +sql select * from $stb limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $stb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +sql select * from $stb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +sql select * from $stb order by ts asc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data24 != 2.000000000 then + return -1 +endi +if $data35 != 3 then + return -1 +endi +if $data49 != nchar4 then + return -1 +endi + +sql select * from $stb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $stb limit 500 offset 1 +if $rows != 99 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi + +$offset = $tbNum * $rowNum +$offset = $offset / 2 +$offset = $offset - 1 +sql select * from $stb limit 2 offset $offset +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data02 != 9 then + return -1 +endi +if $data03 != 9.00000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary9 then + return -1 +endi +if $data09 != nchar9 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data11 != 0 then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != 0.00000 then + return -1 +endi +if $data14 != null then + return -1 +endi +if $data15 != 0 then + return -1 +endi +if $data16 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data18 != binary0 then + return -1 +endi +if $data19 != nchar0 then + return -1 +endi + +$offset = $rowNum * $tbNum +sql select * from lm_stb0 limit 2 offset $offset +if $rows != 0 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 1; +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4; +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +### select from supertable + where + limit offset +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 7 then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data41 != 4 then + return -1 +endi + +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 50 +if $rows != 0 then + return -1 +endi + +sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 7 then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data41 != 4 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +$val = 45 * $rowNum +if $data03 != $val then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary9 then + return -1 +endi +if $data07 != nchar0 then + return -1 +endi + +#sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data02 != 5.000000000 then + return -1 +endi +$val = 5 * $rowNum +$val = $val / 10 +if $data03 != $val then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != binary5 then + return -1 +endi +if $data07 != nchar5 then + return -1 +endi + +sql select c1, tbname, t1 from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6; + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 limit 10 offset 10 +if $rows != 0 then + return -1 +endi + +## TBASE-345 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data18 != 3 then + return -1 +endi +if $data28 != 4 then + return -1 +endi +if $data31 != null then + return -1 +endi +if $data47 != nchar0 then + return -1 +endi +if $data58 != 7 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 0 +if $rows != 6 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != null then + return -1 +endi +if $data02 != 4.500000000 then + return -1 +endi +if $data32 != 4.500000000 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data47 != nchar0 then + return -1 +endi +if $data08 != 7 then + return -1 +endi +if $data18 != 6 then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data53 != 45 then + return -1 +endi +if $data58 != 2 then + return -1 +endi + +### supertable aggregation + where + interval + limit offset +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data41 != 5 then + return -1 +endi +$offset = $rowNum / 2 +$offset = $offset + 1 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset +$val = $rowNum - $offset +if $rows != $val then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data30 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +### supertable aggregation + where + interval + group by order by tag + limit offset +## TBASE-345 +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data22 != 5 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data33 != 6.000000000 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data44 != 5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data58 != nchar6 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 6.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar6 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 5.000000000 then + return -1 +endi +if $data19 != 3 then + return -1 +endi +if $data28 != nchar5 then + return -1 +endi +if $data29 != 2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data23 != 5.000000000 then + return -1 +endi +if $data29 != 3 then + return -1 +endi +if $data39 != 3 then + return -1 +endi +if $data48 != nchar5 then + return -1 +endi +if $data49 != 2 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) group by t1 order by t1 desc limit 1 offset 0 +if $rows != 6 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data09 != 7 then + return -1 +endi +if $data13 != 0.000000000 then + return -1 +endi +if $data19 != 6 then + return -1 +endi +if $data24 != 1 then + return -1 +endi +if $data29 != 5 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != 0 then + return -1 +endi +if $data33 != 0.000000000 then + return -1 +endi +if $data34 != 1 then + return -1 +endi +if $data35 != 0 then + return -1 +endi +if $data36 != 0.000000000 then + return -1 +endi +if $data37 != 0 then + return -1 +endi +if $data38 != 0 then + return -1 +endi +if $data39 != 4 then + return -1 +endi +if $data49 != 3 then + return -1 +endi +if $data59 != 2 then + return -1 +endi + +sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +if $data13 != 3.000000000 then + return -1 +endi +if $data19 != 4 then + return -1 +endi +if $data20 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data24 != 1 then + return -1 +endi +if $data25 != 4 then + return -1 +endi +if $data26 != 0.000000000 then + return -1 +endi +if $data27 != 4 then + return -1 +endi +if $data28 != 4 then + return -1 +endi +if $data29 != 4 then + return -1 +endi + +sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != null then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data09 != 5 then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data19 != 5 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data24 != 0 then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != 1 then + return -1 +endi +if $data29 != 5 then + return -1 +endi +if $data30 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data33 != 1.000000000 then + return -1 +endi +if $data34 != 1 then + return -1 +endi +if $data35 != 0.000000000 then + return -1 +endi +if $data36 != 1 then + return -1 +endi +if $data37 != 1 then + return -1 +endi +if $data38 != 1 then + return -1 +endi +if $data39 != 4 then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data49 != 4 then + return -1 +endi +if $data51 != 3 then + return -1 +endi +if $data59 != 4 then + return -1 +endi + +sql select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data30 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data32 != 7 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 7 then + return -1 +endi +if $data50 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data51 != 8 then + return -1 +endi +if $data52 != 7 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data31 != 6 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data51 != 8 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data21 != 6 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data31 != 8 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data41 != 7 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select top(c1, 101) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc,ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data30 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data32 != 7 then + return -1 +endi +if $data40 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data42 != 7 then + return -1 +endi +if $data50 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 7 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc,ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1 +if $rows != 6 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 1 then + return -1 +endi +if $data30 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data40 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data41 != 2 then + return -1 +endi +if $data42 != 2 then + return -1 +endi +if $data50 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 2 then + return -1 +endi + +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select bottom(c1, 101) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim new file mode 100644 index 0000000000..8fee85cece --- /dev/null +++ b/tests/script/general/parser/limit_tb.sim @@ -0,0 +1,1137 @@ +sleep 3000 +sql connect + +$dbPrefix = lm_db +$tbPrefix = lm_tb +$stbPrefix = lm_stb +$tbNum = 10 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== limit_tb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +##### select from table +print ====== select from table with limit offset +$tb = $tbPrefix . 0 +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data41 != 0 then + return -1 +endi + +$offset = $rowNum - 1 +sql select * from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset 5 +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 4 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary4 then + return -1 +endi +if $data09 != nchar4 then + return -1 +endi + +sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $tb order by ts desc limit 5 offset $offset +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +if $data11 != null then + return -1 +endi +if $data12 != null then + return -1 +endi +if $data13 != null then + return -1 +endi +if $data14 != null then + return -1 +endi + +## TBASE-329 +sql select * from $tb where c1 < 9 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 7 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select * from $tb where c1 < 9 order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 5 then + return -1 +endi + +sql select * from $tb where c1 < 0 order by ts desc limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 1 offset 1 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where c1 > 0 order by ts desc limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data11 != 7 then + return -1 +endi + + +sql_error select * from $tb limit +sql_error select * from $tb offset +sql_error select * from $tb offset 1 +sql_error select * from $tb offset 1 limit 5 +sql_error select * from $tb offset 1 limit -1 + +#### aggregation function + limit offset +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +### aggregation function + limit offset (non-interval case) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu and c1 < 9 and c2 < 8 and c3 >0 and c4 <= 7 and c5 <7 limit 5 offset 0 +if $rows != 1 then + return -1 +endi + +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 0 offset 0 +if $rows != 0 then + return -1 +endi +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 5 +if $rows != 1 then + return -1 +endi +$val = 45 * $rowNum +$val = $val / 10 +print $data05 +print $rowNum +#print $val +if $data00 != $val then + return -1 +endi +if $data01 != 4.500000000 then + return -1 +endi +if $data02 != 2.872281323 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != $rowNum then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary9 then + return -1 +endi +if $data08 != nchar9 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 0 +if $rows != 0 then + return -1 +endi +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1>1 and c2<9 and c3>2 and c4<8 and c5>4 and c6<6 limit 1 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 5.000000000 then + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 != 5.000000000 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data07 != binary5 then + return -1 +endi +if $data08 != nchar5 then + return -1 +endi + +sql select sum(c1), avg(c2), stddev(c3), max(c4), min(c5), count(c6), first(c7), last(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 5400000.000000000 then + return -1 +endi +if $data01 != 9.000000000 then + return -1 +endi +if $data02 != 9.000000000 then + return -1 +endi +if $data03 != 9.000000000 then + return -1 +endi +if $data04 != 9.000000000 then + return -1 +endi +if $data05 != 9.000000000 then + return -1 +endi +if $data06 != 9.000000000 then + return -1 +endi +sql select spread(ts), spread(c1), spread(c2), spread(c3), spread(c4), spread(c5), spread(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data01 != 4.000000000 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 4.000000000 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select top(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data21 != 6 then + return -1 +endi + +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data11 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data21 != 8 then + return -1 +endi +sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5 +if $rows != 0 then + return -1 +endi +sql_error select top(c1, 101) from $tb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 98 + +sql select bottom(c1, 1) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data21 != 3 then + return -1 +endi +sql select bottom(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 5 +if $rows != 0 then + return -1 +endi + +sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +### aggregation + limit offset (with interval) +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.00000 then + return -1 +endi +if $data04 != 1.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi + +## TBASE-334 +sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1 +if $rows != 2 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data11 != 8 then + return -1 +endi +if $data14 != 8.000000000 then + return -1 +endi +if $data21 != null then + return -1 +endi + +sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 6 then + return -1 +endi +if $data21 != 9 then + return -1 +endi +if $data31 != null then + return -1 +endi + +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 +if $rows != 4 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 21 then + return -1 +endi +if $data31 != 9 then + return -1 +endi +if $data41 != null then + return -1 +endi +sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 12 then + return -1 +endi +if $data11 != 21 then + return -1 +endi +if $data21 != 9 then + return -1 +endi +if $data31 != null then + return -1 +endi + +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +if $data11 != 4.000000000 then + return -1 +endi +if $data21 != 7.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi +sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 4.000000000 then + return -1 +endi +if $data11 != 7.000000000 then + return -1 +endi +if $data21 != 9.000000000 then + return -1 +endi +if $data31 != null then + return -1 +endi + + +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 0 +if $rows != 0 then + return -1 +endi +sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data01 != 0.816496581 then + return -1 +endi +if $data10 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi + +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) +if $rows != 4 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi +if $data21 != 3 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 1 +if $rows != 0 then + return -1 +endi + +sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 3 offset 0 +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi + +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 3 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + + +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1 +if $rows != 0 then + return -1 +endi +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 9.00000 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data12 != 3 then + return -1 +endi +if $data13 != 5 then + return -1 +endi +if $data14 != 3.00000 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data23 != 8 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data29 != nchar8 then + return -1 +endi + +sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1 +if $rows != 3 then + return -1 +endi +if $data01 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data08 != binary3 then + return -1 +endi +if $data09 != nchar5 then + return -1 +endi +if $data12 != 6 then + return -1 +endi +if $data13 != 8 then + return -1 +endi +if $data14 != 6.00000 then + return -1 +endi +if $data15 != 8.000000000 then + return -1 +endi +if $data22 != 9 then + return -1 +endi +if $data23 != 9 then + return -1 +endi +if $data24 != 9.00000 then + return -1 +endi +if $data25 != 9.000000000 then + return -1 +endi +if $data26 != 9 then + return -1 +endi +if $data27 != 9 then + return -1 +endi +if $data28 != binary9 then + return -1 +endi +if $data29 != nchar9 then + return -1 +endi + +### order by ts + limit offset + +sql select * from $tb order by ts asc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data23 != 2.00000 then + return -1 +endi +if $data34 != 3.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary2 then + return -1 +endi +if $data39 != nchar3 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:20:00.000@ then + return -1 +endi +if $data12 != 2 then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi +if $data34 != 4.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 1 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary3 then + return -1 +endi +if $data39 != nchar4 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts asc limit 5 offset 8 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi + +sql select * from $tb where c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data10 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data12 != 5 then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi + +sql select * from $tb where c1 < 3 and c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset 2 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data04 != 4.000000000 then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:30:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data10 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data20 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data23 != 7.00000 then + return -1 +endi +if $data34 != 6.000000000 then + return -1 +endi +if $data45 != 5 then + return -1 +endi +if $data06 != 9 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary7 then + return -1 +endi +if $data39 != nchar6 then + return -1 +endi +if $data40 != @18-09-17 09:50:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 1 +if $rows != 5 then + return -1 +endi +if $data00 != @18-09-17 10:20:00.000@ then + return -1 +endi +if $data01 != 8 then + return -1 +endi +if $data10 != @18-09-17 10:10:00.000@ then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != @18-09-17 10:00:00.000@ then + return -1 +endi +if $data23 != 6.00000 then + return -1 +endi +if $data34 != 5.000000000 then + return -1 +endi +if $data45 != 4 then + return -1 +endi +if $data06 != 8 then + return -1 +endi +if $data17 != 1 then + return -1 +endi +if $data28 != binary6 then + return -1 +endi +if $data39 != nchar5 then + return -1 +endi +if $data40 != @18-09-17 09:40:00.000@ then + return -1 +endi + +sql select * from $tb order by ts desc limit 5 offset 8 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:10:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data12 != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 order by ts desc limit 3 offset 2 +if $rows != 3 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data10 != @18-09-17 09:40:00.000@ then + return -1 +endi +if $data20 != @18-09-17 09:30:00.000@ then + return -1 +endi +if $data12 != 4 then + return -1 +endi +if $data23 != 3.00000 then + return -1 +endi + +sql select * from $tb where c1 < 8 and c1 > 6 order by ts desc limit 3 offset 2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where c1 < 8 and c1 > 4 order by ts desc limit 3 offset 2 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:50:00.000@ then + return -1 +endi +if $data01 != 5 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi + diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim new file mode 100644 index 0000000000..03c3a77a89 --- /dev/null +++ b/tests/script/general/parser/mixed_blocks.sim @@ -0,0 +1,144 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = mb_db +$tbPrefix = mb_tb +$stbPrefix = mb_stb +$tbNum = 10 +$ts0 = 1537146000000 +$delta = 1000 +print ========== mixed_blocks.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +$paramRows = 200 +$rowNum = $paramRows * 4 +$rowNum = $rowNum / 5 +sql create database $db rows $paramRows tables 4 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$tb1 = $tbPrefix . 1 +$tb2 = $tbPrefix . 2 +sql create table $tb1 using $stb tags( 1 ) +sql create table $tb2 using $stb tags( 2 ) + +$tb1 = $tbPrefix . 1 +$tb2 = $tbPrefix . 2 +$x = 0 +print rowNum = $rowNum +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + $c = 0 - $x + sql insert into $tb1 values ( $ts , $x , $x , $x , $x , true, $binary , $nchar ) + sql insert into $tb2 values ( $ts , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 +endw +print ====== tables created +sql show databases + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +$rowNum = $rowNum * 2 +while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + $c = 0 - $x + sql insert into $tb1 values ( $ts , $x , $x , $x , $x , true, $binary , $nchar ) + sql insert into $tb2 values ( $ts , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 +endw + +#### query a STable and using where clause to filter out all the data from tb2 and make the query only return first/last of tb1 +sql select first(ts,c1), last(ts,c1), spread(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:05:19.000@ then + return -1 +endi +if $data03 != 319 then + return -1 +endi +if $data04 != 318.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select max(c1), min(c1), sum(c1), avg(c1), count(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 319 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 51040 then + return -1 +endi +if $data03 != 160.000000000 then + return -1 +endi +if $data04 != 319 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(ts,c1), last(ts,c1) from $tb1 where c1 > 0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:05:19.000@ then + return -1 +endi +if $data03 != 319 then + return -1 +endi diff --git a/tests/script/general/parser/nchar.sim b/tests/script/general/parser/nchar.sim new file mode 100644 index 0000000000..b6c3a3c9bb --- /dev/null +++ b/tests/script/general/parser/nchar.sim @@ -0,0 +1,310 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = nchar_db +$tbPrefix = nchar_tb +$mtPrefix = nchar_stb +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 +$col = NCHAR + +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db + +# case1: create_metric_with_nchar_data +print ========== nchar.sim case1: create_table_with_nchar_data test + +# unspecified nchar length +sql_error create table $mt (ts timestamp, col nchar) +sql_error create table $mt (ts timestamp, col int) tags (tg nchar) +# nchar as column or tag names +sql_error create table $mt (ts timestamp, nchar int) +sql_error create table $mt (ts timestamp, col int) tags (nchar int) +sql create table $mt (ts timestamp, col nchar(60)) tags (tg nchar(60)) +sql show stables +if $rows != 1 then + return -1 +endi +if $data00 != $mt then + return -1 +endi +sql describe $mt +if $rows != 3 then + return -1 +endi +if $data11 != NCHAR then + return -1 +endi +sql create table $tb using $mt tags ('tag1') +sql describe $tb +if $data11 != NCHAR then + return -1 +endi +if $data21 != NCHAR then + return -1 +endi +sql drop table $tb +sql drop table $mt +print create_metric_with_nchar_data test passed + +# case2 : insert_nchar_data +#print ========== nchar.sim case2: insert_nchar_data +sql create table $mt (ts timestamp, col nchar(10)) tags(tg nchar(10)) +sql create table $tb using $mt tags ('tag1') +sql describe $mt +#print expected: NCHAR +#print returned: $data11 +if $data11 != NCHAR then + return -1 +endi + +# insert nchar data with a pair of single quotes +$col = 'NCHAR' +$col_ = NCHAR +sql insert into $tb values (now, $col ) +sql select * from $tb order by ts desc +print expected: $col_ +print returned: $data01 +if $data01 != $col_ then + return -1 +endi + +# insert nchar data with a pair of double quotes +$col = "NCHAR" +$col_ = NCHAR +sql insert into $tb values (now, $col ) +sql select * from $tb order by ts desc +print expected: $col_ +print returned: $data01 +if $data01 != $col_ then + return -1 +endi + +# insert nchar data without quotes +$col = NCHAR +$col_ = nchar +sql_error insert into $tb values (now, $col ) +sql select * from $tb order by ts desc +#print expected: $col_ +#print returned: $data01 +#if $data01 != $col_ then +# return -1 +#endi + +# insert nchar data with space and no quotes +sql_error insert into $tb values (now, n char ) + +# insert nchar data with space and a pair of single quotes +sql insert into $tb values (now, 'NCHAR' ) +sql select * from $tb order by ts desc +print expected: NCHAR +print returned: $data01 +$quote = ' +$ret1 = $quote . $data01 +$ret2 = $ret1 . $quote +print $ret2 + +if $ret2 != 'NCHAR' then + return -1 +endi + +label1: + +# insert nchar data with space and a pair of double quotes +sql insert into $tb values (now, "NCHAR" ) +sql select * from $tb order by ts desc +print expected: N CHAR +print returned: $data01 +$quote = " +$ret1 = $quote . $data01 +$ret2 = $ret1 . $quote +print $ret2 +if $ret2 = "NCHAR" then + goto label2 +else + return -1 +endi +label2: + +sql insert into $tb values (now, "涛æ€" ) +sql select * from $tb order by ts desc +print expected: æ¶›æ€ +print returned: $data01 +if $data01 != æ¶›æ€ then + return -1 +endi + +# insert nchar data with a single quote and a double quote +#sql insert into $tb values (now, 'NCHAR") +sql_error insert into $tb values (now, 'NCHAR") +sql_error insert into $tb values (now, 'NCHAR]) + +sql drop table $tb +sql drop table $mt +sql reset query cache +# create multiple metrics and tables and insert nchar type data +sql create table $mt (ts timestamp, tbcol nchar(10), tbcol1 int) TAGS(tgcol nchar(10)) +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '0', $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '1', $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +# case5: query_with_tag_filtering +print ========== nchar.sim case5: query test +# simple query with nchar tag filtering +sql select * from $mt where tgcol = '1' -x step1 + goto step2 +step1: +print reset query cache +sql reset query cache +sql select * from $mt where tgcol = '1' +step2: +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol > '0' +#print rows = $rows +if $rows != 100 then + return -1 +endi +#print $data03 +if $data03 != 1 then + return -1 +endi + +# cumulative query with nchar tag filtering +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +sql select count(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +print data00 = $data00 +if $data00 != 5 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +sql_error select avg(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select sum(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select min(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql_error select max(tbcol) from $mt where tbcol1 = 1 group by tgcol +sql select first(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +sql select last(tbcol) from $mt where tbcol1 = 1 group by tgcol +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql create table stbb (ts timestamp, c1 nchar(5)) tags (t1 int) +sql create table tbb1 using stbb tags(1) +sql insert into tbb1 values ('2018-09-17 09:00:00', '涛æ€') +sql insert into tbb1 values ('2018-09-17 09:00:01', 'insrt') +sql select * from tbb1 order by ts asc +if $rows != 2 then + return -1 +endi +print data11 = $data11 +if $data11 != insrt then + return -1 +endi + +sql select * from stbb +if $rows != 2 then + return -1 +endi +if $data11 != insrt then + return -1 +endi + +# nchar data column currently does not support filtering, 2018/09/27 +# sql select * from $mt where tbcol = '0' +# if $rows != 100 then +# return -1 +# endi +# +# sql select * from $mt where ts > now + 4m and tbcol = '1' +# if $rows != 75 then +# return -1 +# endi +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol +# +# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol +# +# case: query_with_wildcard +# print =============== clear +# sql drop database $db +# sql show databases +# if $rows != 0 then +# return -1 +# endi diff --git a/tests/script/general/parser/null_char.sim b/tests/script/general/parser/null_char.sim new file mode 100644 index 0000000000..eeb94708d9 --- /dev/null +++ b/tests/script/general/parser/null_char.sim @@ -0,0 +1,491 @@ +#### TBASE-679 +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 3 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 3 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ========== null_char.sim + +$db = db +sql drop database if exists $db +sql create database $db +sql use $db + +#### case 0: field null, or 'null' +sql create table mt1 (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(8), col6 bool, col7 smallint, col8 tinyint, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag4 bigint, tag5 bool, tag6 float) +sql create table st1 using mt1 tags (null, 'null', 100, 1000, 'false', 9.123) +sql insert into st1 values ('2019-01-01 09:00:00.000', 123, -123, 3.0, 4.0, 'binary', true, 1000, 121, 'nchar') +sql insert into st1 values ('2019-01-01 09:00:01.000', '456', '456', '3.33', '4.444', 'binary', 'true', '1001', '122', 'nchar') +sql insert into st1 values ('2019-01-01 09:00:02.000', null, null, null, null, null, null, null, null, null) +sql insert into st1 values ('2019-01-01 09:00:03.000', null, null, null, null, 'null', 'null', 2002, 127, 'null') + +sql select * from mt1 +if $rows != 4 then + return -1 +endi +if $data21 != null then + return -1 +endi +if $data22 != null then + return -1 +endi +if $data23 != null then + return -1 +endi +if $data24 != null then + return -1 +endi +if $data25 != null then + return -1 +endi +if $data26 != null then + return -1 +endi +if $data27 != null then + return -1 +endi +if $data28 != null then + return -1 +endi +if $data29 != null then + return -1 +endi + +if $data31 != null then + return -1 +endi +if $data32 != null then + return -1 +endi +#if $data33 != 0.00000 then +# print === expect 0.00000, actually $data33 +# return -1 +#endi +#if $data34 != 0.000000000 then +# print === expect 0.00000, actually $data34 +# return -1 +#endi +if $data35 != null then + return -1 +endi +if $data36 != null then + return -1 +endi +if $data39 != null then + return -1 +endi + + +#### case 1: tag null, or 'null' +sql create table mt2 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) +sql create table st2 using mt2 tags (null, 'null', 102, 'true') +sql describe st2 +if $rows != 10 then + return -1 +endi +if $data63 != NULL then + print ==1== expect: NULL, actually: $data63 + return -1 +endi +if $data73 != null then + print ==2== expect: NULL, actually: $data73 + return -1 +endi +if $data83 != 102 then + print ==3== expect: NULL, actually: $data83 + return -1 +endi +if $data93 != true then + print ==4== expect: NULL, actually: $data93 + return -1 +endi + +sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE') +sql describe st3 +if $rows != 10 then + return -1 +endi +if $data63 != NULL then + print ==5== expect: NULL, actually: $data63 + return -1 +endi +if $data73 != ABC then + return -1 +endi +if $data83 != 103 then + return -1 +endi +if $data93 != false then + return -1 +endi + +### bool: +sql_error create table stx using mt2 tags ('NULL', '123aBc', 104, '123') +sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') +sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'null') +sql describe st4 +if $rows != 10 then + return -1 +endi +if $data63 != NULL then + return -1 +endi +if $data73 != 123aBc then + return -1 +endi +if $data83 != 104 then + return -1 +endi +if $data93 != NULL then + print ==6== expect: NULL, actually: $data93 + return -1 +endi + +sql create table st5 using mt2 tags ('NULL', '123aBc', 105, NULL) +sql describe st5 +if $rows != 10 then + return -1 +endi +if $data63 != NULL then + return -1 +endi +if $data73 != 123aBc then + return -1 +endi +if $data83 != 105 then + return -1 +endi +if $data93 != NULL then + return -1 +endi + + + +#### case 2: dynamic create table using super table when insert into +sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) +sql_error insert into st31 using mt3 tags (null, 'null', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') +sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32') +sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'null') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') +sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34') + + +#### case 3: set tag value +sql create table mt4 (ts timestamp, c1 int) tags (tag_binary binary(16), tag_nchar nchar(16), tag_int int, tag_bool bool, tag_float float, tag_double double) +sql create table st41 using mt4 tags ("beijing", 'nchar_tag', 100, false, 9.12345, 7.123456789) +sql describe st41 +if $rows != 8 then + return -1 +endi +if $data23 != beijing then + return -1 +endi +if $data33 != nchar_tag then + return -1 +endi +if $data43 != 100 then + return -1 +endi +if $data53 != false then + return -1 +endi +if $data63 != 9.123450 then + return -1 +endi +if $data73 != 7.123457 then + return -1 +endi +################# binary +sql alter table st41 set tag tag_binary = "shanghai" +sql describe st41 +if $data23 != shanghai then + return -1 +endi +##### test 'space' case +#$tagvalue = ' +#$tagvalue = $tagvalue ' +#sql alter table st41 set tag tag_binary = $tagvalue +sql alter table st41 set tag tag_binary = "" +#sql describe st41 +#if $data23 != $tagvalue then +# return -1 +#endi +sql alter table st41 set tag tag_binary = "null" +sql describe st41 +if $data23 != null then + return -1 +endi +sql alter table st41 set tag tag_binary = NULL +sql describe st41 +if $data23 != NULL then + print ==8== expect: NULL, actually: $data23 + return -1 +endi + +################### nchar +sql alter table st41 set tag tag_nchar = "��˼����" +sql describe st41 +#sleep 1000 +#if $data33 != ��˼���� then +# print ==== expect ��˼����, actually $data33 +# return -1 +#endi +##### test 'space' case +#$tagvalue = ' +#$tagvalue = $tagvalue ' +sql alter table st41 set tag tag_nchar = '' +#sql describe st41 +#if $data33 != $tagvalue then +# return -1 +#endi +sql alter table st41 set tag tag_nchar = "null" +sql describe st41 +if $data33 != null then + return -1 +endi +sql alter table st41 set tag tag_nchar = NULL +#sql describe st41 +#if $data33 != then +# print ==9== expect , actually $data33 +# return -1 +#endi + +################### int +sql alter table st41 set tag tag_int = -2147483647 +sql describe st41 +if $data43 != -2147483647 then + return -1 +endi +sql alter table st41 set tag tag_int = 2147483647 +sql describe st41 +if $data43 != 2147483647 then + return -1 +endi + +sql_error alter table st41 set tag tag_int = -2147483648 +sql_error alter table st41 set tag tag_int = 2147483648 + +sql alter table st41 set tag tag_int = '-379' +sql describe st41 +if $data43 != -379 then + return -1 +endi +sql alter table st41 set tag tag_int = -2000 +sql describe st41 +if $data43 != -2000 then + return -1 +endi +sql alter table st41 set tag tag_int = null +sql describe st41 +if $data43 != NULL then + print ==10== expect: NULL, actually: $data43 + return -1 +endi +sql alter table st41 set tag tag_int = 'null' +sql_error alter table st41 set tag tag_int = '' +sql_error alter table st41 set tag tag_int = abc379 + +################### bool +sql alter table st41 set tag tag_bool = 'true' +sql describe st41 +if $data53 != true then + return -1 +endi +sql alter table st41 set tag tag_bool = 'false' +sql describe st41 +if $data53 != false then + return -1 +endi +sql alter table st41 set tag tag_bool = 0 +sql describe st41 +if $data53 != false then + return -1 +endi +sql alter table st41 set tag tag_bool = 123 +sql describe st41 +if $data53 != true then + return -1 +endi +sql alter table st41 set tag tag_bool = 'null' +sql describe st41 +if $data53 != NULL then + print ==14== expect: NULL, actually: $data53 + return -1 +endi +sql alter table st41 set tag tag_bool = null +sql describe st41 +if $data53 != NULL then + return -1 +endi + +sql_error alter table st41 set tag tag_bool = '123' +sql_error alter table st41 set tag tag_bool = '' +sql_error alter table st41 set tag tag_bool = abc379 + +################### float +sql alter table st41 set tag tag_float = -32 +sql describe st41 +if $data63 != -32.000000 then + return -1 +endi +sql alter table st41 set tag tag_float = 54.123456 +sql describe st41 +if $data63 != 54.123455 then + print ==15== expect: 54.123455, actually: $data63 +# return -1 +endi +sql alter table st41 set tag tag_float = 54.12345 +sql describe st41 +if $data63 != 54.123451 then + print ==16== expect: 54.123451, actually: $data63 + return -1 +endi +sql alter table st41 set tag tag_float = 54.12345678 +sql describe st41 +if $data63 != 54.123455 then + print ==11== expect: 54.123455, actually : $data63 + return -1 +endi +sql alter table st41 set tag tag_float = null +sql describe st41 +if $data63 != NULL then + print ==12== expect: NULL, actually : $data63 + return -1 +endi +sql alter table st41 set tag tag_float = 'null' +sql describe st41 +if $data63 != NULL then + print ==17== expect: NULL, actually : $data63 + return -1 +endi +sql alter table st41 set tag tag_float = '54.123456' +sql describe st41 +if $data63 != 54.123455 then + print ==18== expect: 54.123455, actually : $data63 + return -1 +endi +sql alter table st41 set tag tag_float = '-54.123456' +sql describe st41 +if $data63 != -54.123455 then + print ==19== expect: -54.123455, actually : $data63 + return -1 +endi +sql_error alter table st41 set tag tag_float = '' + +sql_error alter table st41 set tag tag_float = 'abc' +sql_error alter table st41 set tag tag_float = '123abc' +sql_error alter table st41 set tag tag_float = abc + +################### double +sql alter table st41 set tag tag_double = -92 +sql describe st41 +if $data73 != -92.000000 then + return -1 +endi +sql alter table st41 set tag tag_double = 184 +sql describe st41 +if $data73 != 184.000000 then + return -1 +endi +sql alter table st41 set tag tag_double = '-2456' +sql describe st41 +if $data73 != -2456.000000 then + return -1 +endi +sql alter table st41 set tag tag_double = null +sql describe st41 +if $data73 != NULL then + print ==13== expect: NULL, actually : $data73 + return -1 +endi +sql alter table st41 set tag tag_double = 'null' +sql describe st41 +if $data73 != NULL then + print ==20== expect: NULL, actually : $data73 + return -1 +endi +sql_error alter table st41 set tag tag_double = '' + + +sql_error alter table st41 set tag tag_double = 'abc' +sql_error alter table st41 set tag tag_double = '123abc' +sql_error alter table st41 set tag tag_double = abc + +################### bigint smallint tinyint +sql create table mt5 (ts timestamp, c1 int) tags (tag_bigint bigint, tag_smallint smallint, tag_tinyint tinyint) +sql create table st51 using mt5 tags (1, 2, 3) +sql alter table st51 set tag tag_bigint = '-379' +sql alter table st51 set tag tag_bigint = -2000 +sql alter table st51 set tag tag_bigint = null +sql alter table st51 set tag tag_bigint = 9223372036854775807 +sql describe st51 +if $data23 != 9223372036854775807 then + return -1 +endi +sql alter table st51 set tag tag_bigint = 9223372036854775808 +sql describe st51 +if $data23 != 9223372036854775807 then + return -1 +endi +sql alter table st51 set tag tag_bigint = -9223372036854775807 +sql describe st51 +if $data23 != -9223372036854775807 then + return -1 +endi +sql_error alter table st51 set tag tag_bigint = -9223372036854775808 + + +sql alter table st51 set tag tag_bigint = 'null' +sql_error alter table st51 set tag tag_bigint = '' +sql_error alter table st51 set tag tag_bigint = abc379 + +#### +sql alter table st51 set tag tag_smallint = -2000 +sql alter table st51 set tag tag_smallint = null +sql alter table st51 set tag tag_smallint = 32767 +sql describe st51 +if $data33 != 32767 then + return -1 +endi +sql_error alter table st51 set tag tag_smallint = 32768 + +sql alter table st51 set tag tag_smallint = -32767 +sql describe st51 +if $data33 != -32767 then + return -1 +endi +sql_error alter table st51 set tag tag_smallint = -32768 + +sql alter table st51 set tag tag_smallint = 'null' +sql_error alter table st51 set tag tag_smallint = '' +sql_error alter table st51 set tag tag_smallint = abc379 + +#### +sql alter table st51 set tag tag_tinyint = -127 +sql alter table st51 set tag tag_tinyint = null +sql alter table st51 set tag tag_tinyint = 127 +sql describe st51 +if $data43 != 127 then + return -1 +endi +sql alter table st51 set tag tag_tinyint = -127 +sql describe st51 +if $data43 != -127 then + return -1 +endi +sql_error alter table st51 set tag tag_tinyint = '-128' +sql_error alter table st51 set tag tag_tinyint = 128 +sql alter table st51 set tag tag_tinyint = 'null' +sql_error alter table st51 set tag tag_tinyint = '' +sql_error alter table st51 set tag tag_tinyint = abc379 + + +# test end +#sql drop database $db + + diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim new file mode 100644 index 0000000000..2f18e3cf34 --- /dev/null +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -0,0 +1,378 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt +$tbNum = 8 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== projection_limit_offset.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exits $db -x step1 +step1: +sql create database if not exists $db tables 4 keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +$i1 = 1 +$i2 = 0 + +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$dbPrefix = group_db +$tbPrefix = group_tb +$mtPrefix = group_mt + +$tb1 = $tbPrefix . $i1 +$tb2 = $tbPrefix . $i2 +$ts1 = $tb1 . .ts +$ts2 = $tb2 . .ts + +#===============select * from super_table limit/offset[TBASE-691]================================= +sql select ts from group_mt0 +print $rows + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 0; +if $rows != 4008 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 1; +if $rows != 4007 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 101; +print $rows +if $rows != 3907 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.101@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 902; +if $rows != 3106 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 400; +if $rows != 3608 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 4007; +if $rows != 1 then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 2000 offset 4008; +if $rows != 0 then + return -1 +endi + +#==================================order by desc, multi vnode, limit/offset=================================== +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 0; +if $rows != 4008 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.500@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 1; +if $rows != 4007 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.499@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 101; +print $rows +if $rows != 3907 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.399@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 902; +if $rows != 3106 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.099@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 400; +if $rows != 3608 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.100@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 4007; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 2000 offset 4008; +if $rows != 0 then + return -1 +endi + +#=================================single value filter====================================== +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 0; +if $row != 8 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 1; +if $row != 7 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 2; +if $row != 6 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 4; +if $row != 4 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 7; +if $row != 1 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 8; +if $row != 0 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 9; +if $row != 0 then + return -1 +endi + +#===============================single value filter, order by desc============================ +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 0; +if $row != 8 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 1; +if $row != 7 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 2; +if $row != 6 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 4; +if $row != 4 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 7; +if $row != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:43.000@ then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 8; +if $row != 0 then + return -1 +endi + +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 9; +if $row != 0 then + return -1 +endi + +#[tbase-695] +sql select ts,tbname from group_mt0 where ts>='1970-01-01 8:1:40' and ts<'1970-1-1 8:1:45' and c1<99999999 limit 100000 offset 5000 +if $row != 35000 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +#=================================parse error sql========================================== +sql_error select ts,tbname from group_mt0 order by ts desc limit 100 offset -1; +sql_error select ts,tbname from group_mt0 order by c1 asc limit 100 offset -1; +sql_error select ts,tbname from group_mt0 order by ts desc limit -1, 100; +sql_error select ts,tbname from group_mt0 order by ts desc slimit -1, 100; +sql_error select ts,tbname from group_mt0 order by ts desc slimit 1 soffset 1; + +#================================functions applys to sql=================================== +sql_error select first(t1) from group_mt0; +sql_error select last(t1) from group_mt0; +sql_error select min(t1) from group_mt0; +sql_error select max(t1) from group_mt0; +sql_error select top(t1, 20) from group_mt0; +sql_error select bottom(t1, 20) from group_mt0; +sql_error select avg(t1) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; +sql_error select percentile(t1, 50) from group_mt0; + +#====================================tbase-722============================================== +print tbase-722 +sql select spread(ts) from group_tb0; +print $data00 + +if $data00 != 9999.000000000 then + return -1 +endi + +#====================================tbase-716============================================== +print tbase-716 +sql_error select count(*) from group_tb0 where ts in ('2016-1-1 12:12:12'); +sql_error select count(*) from group_tb0 where ts < '12:12:12'; + +#===============================sql for twa========================================== +sql_error select twa(c1) from group_tb0; +sql_error select twa(c1) from group_stb0; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by t1; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by tbname,t1; +sql_error select twa(c2) from group_stb0 group by tbname,t1; +sql_error select twa(c2) from group_stb0 group by tbname; +sql_error select twa(c2) from group_stb0 group by t1; +sql_error select twa(c2) from group_stb0 where tsnow-1h group by t1,tbname; + +#================================first/last error check================================ +sql create table m1 (ts timestamp, k int) tags(a int); +sql create table tm0 using m1 tags(1); +sql create table tm1 using m1 tags(2); + +sql insert into tm0 values(10000, 1) (20000, 2)(30000, 3) (40000, NULL) (50000, 2) tm1 values(10001, 2)(20000,4)(90000,9); +sql select count(*),first(k),last(k) from m1 where tbname in ('tm0') interval(1s) order by ts desc; + +if $row != 5 then + return -1 +endi + +if $data00 != @70-01-01 08:00:50.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +if $data02 != 2 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != null then + return -1 +endi + +if $data13 != null then + return -1 +endi + +print =============tbase-1324 +sql select a, k-k from m1 +if $row != 8 then + return -1 +endi + +#error sql +sql_error select * from 1; +sql_error select 1; +sql_error select k+k; +sql_error select k+1; +sql_error select abc(); +sql_error select 1 where 1=2; +sql_error select 1 limit 1; +sql_error select 1 slimit 1; +sql_error select 1 interval(1h); +sql_error select count(*); +sql_error select sum(k); +sql_error select 'abc'; + +#=============================tbase-1205 +sql select count(*) from tm1 where ts= now -1d interval(1h) fill(NULL); + + diff --git a/tests/script/general/parser/repeatAlter.sim b/tests/script/general/parser/repeatAlter.sim new file mode 100644 index 0000000000..eec82f62c0 --- /dev/null +++ b/tests/script/general/parser/repeatAlter.sim @@ -0,0 +1,7 @@ +$i = 1 +$loops = 10 +while $i <= $loops + print ====== repeat: $i + run lite/parser/alter.sim + $i = $i + 1 +endw diff --git a/tests/script/general/parser/repeatStream.sim b/tests/script/general/parser/repeatStream.sim new file mode 100644 index 0000000000..1301462c31 --- /dev/null +++ b/tests/script/general/parser/repeatStream.sim @@ -0,0 +1,7 @@ +$i = 1 +$repeats = 5 +while $i <= $repeats + print ====== repeat: $i + run lite/parser/stream.sim + $i = $i + 1 +endw diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/general/parser/selectResNum.sim new file mode 100644 index 0000000000..3065c7eca0 --- /dev/null +++ b/tests/script/general/parser/selectResNum.sim @@ -0,0 +1,184 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = sc_db +$tbPrefix = sc_tb +$stbPrefix = sc_stb +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum +$loops = 200000 +$log = 10000 +$ts0 = 1537146000000 +$delta = 600000 +print ========== selectResNum.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db cache 2048 tables 200 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $tbId = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $tbId + sql create table $tb using $stb tags( $i ) + sql create table $tb1 using $stb tags( $tbId ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sql use $db +##### select from table +print ====== select from table and check num of rows returned +$loop = 1 +$i = 0 +while $loop <= $loops + $remainder = $loop / $log + $remainder = $remainder * $log + $remainder = $loop - $remainder + if $remainder == 0 then + print loop: $loop + endi + while $i < 10 + sql select ts from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c1 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c2 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c3 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c4 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c5 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c6 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c7 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c8 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c9 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + $i = $i + 1 + endw + $loop = $loop + 1 +endw + +print ====== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 6000 +system sh/exec.sh -n dnode1 -s start +print ====== server restart completed +sleep 3000 +sql connect +sleep 3000 +sql use $db + +##### repeat test after server restart +print ====== repeat test after restarting server +$loop = 1 +$i = 0 +while $loop <= $loops + $remainder = $loop / $log + $remainder = $remainder * $log + $remainder = $loop - $remainder + if $remainder == 0 then + print loop: $loop + endi + while $i < 10 + sql select ts from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c1 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c2 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c3 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c4 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c5 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c6 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c7 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c8 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + sql select c9 from $stb where t1 = $i + if $rows != $rowNum then + return -1 + endi + $i = $i + 1 + endw + $loop = $loop + 1 +endw diff --git a/tests/script/general/parser/select_across_vnodes.sim b/tests/script/general/parser/select_across_vnodes.sim new file mode 100644 index 0000000000..875036082d --- /dev/null +++ b/tests/script/general/parser/select_across_vnodes.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 5 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = sav_db +$tbPrefix = sav_tb +$stbPrefix = sav_stb +$tbNum = 20 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== alter.sim +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db +print ====== create tables +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $stb tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'æ¶›æ€ . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +##### select * from stb +sql select * from $stb +if $rows != $totalNum then + return -1 +endi + +##### select * from $stb with limit +sql select * from $stb limit 1 +if $rows != 1 then + return -1 +endi + +$limit = $rowNum / 2 +sql select * from $stb limit $limit +if $rows != $limit then + return -1 +endi + +sql select last(*) from $stb where t1 >= 0 group by t1 limit 5 +if $rows != $tbNum then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/select_from_cache_disk.sim b/tests/script/general/parser/select_from_cache_disk.sim new file mode 100644 index 0000000000..a60571b7d1 --- /dev/null +++ b/tests/script/general/parser/select_from_cache_disk.sim @@ -0,0 +1,70 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = scd_db +$tbPrefix = scd_tb +$stbPrefix = scd_stb +$tbNum = 20 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== select_from_cache_disk.sim +$i = 0 +$db = $dbPrefix +$stb = $stbPrefix +$tb = $tbPrefix + +sql drop database if exists $db +sql create database $db +sql use $db +print ====== create tables +sql create table $stb (ts timestamp, c1 int) tags(t1 int) +sql create table $tb using $stb tags( 1 ) +# generate some data on disk +sql insert into $tb values ('2018-09-17 09:00:00.000', 0) +sql insert into $tb values ('2018-09-17 09:00:00.010', 1) +sql insert into $tb values ('2018-09-17 09:00:00.020', 2) +sql insert into $tb values ('2018-09-17 09:00:00.030', 3) + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 +sql use $db + +# generate some data in cache +sql insert into $tb values ('2018-09-17 09:00:04.000', 4) +sql insert into $tb values ('2018-09-17 09:00:04.010', 5) +sql select count(*) from $stb interval(1s) group by t1 +if $rows != 2 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != @18-09-17 09:00:04.000@ then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 1 then + return -1 +endi diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim new file mode 100644 index 0000000000..8558323eba --- /dev/null +++ b/tests/script/general/parser/select_with_tags.sim @@ -0,0 +1,840 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 1000 +sql connect + +$dbPrefix = select_tags_db +$tbPrefix = select_tags_tb +$mtPrefix = select_tags_mt + +$tbNum = 16 +$rowNum = 800 +$totalNum = $tbNum * $rowNum + +print =============== select_with_tags.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db tables 4 keep 36500 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$i = 0 +$j = 1 + +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . $i + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $c1 = $c + $i + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c1 , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $j = $j + 10000 + $tstart = 100000 + $j + +endw + +sleep 100 + +#================================ +sql select ts from select_tags_mt0 +print $rows +if $rows != 12800 then + return -1 +endi + +sql select first(ts), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != @select_tags_tb0@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +sql select last(ts), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != @70-01-01 08:04:10.800@ then + return -1 +endi + +if $data01 != @select_tags_tb15@ then + return -1 +endi + +if $data02 != 15 then + return -1 +endi + +if $data03 != @abc15@ then + return -1 +endi + +sql select min(c1), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != @select_tags_tb0@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +sql select max(c1), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 114 then + return -1 +endi + +if $data01 != @select_tags_tb15@ then + return -1 +endi + +if $data02 != 15 then + return -1 +endi + +if $data03 != @abc15@ then + return -1 +endi + +sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0; +if $rows != 100 then + return -1 +endi + +if $data00 != @70-01-01 08:03:30.100@ then + return -1 +endi + +if $data10 != @70-01-01 08:03:30.200@ then + return -1 +endi + +if $data01 != 110 then + return -1 +endi + +if $data02 != @select_tags_tb11@ then + return -1 +endi + +if $data03 != 11 then + return -1 +endi + +if $data04 != @abc11@ then + return -1 +endi + +sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0; +if $rows != 80 then + return -1 +endi + +if $data00 != @70-01-01 08:03:40.100@ then + return -1 +endi + +if $data10 != @70-01-01 08:03:40.200@ then + return -1 +endi + +if $data01 != 111 then + return -1 +endi + +if $data02 != @select_tags_tb12@ then + return -1 +endi + +if $data03 != 12 then + return -1 +endi + +if $data04 != @abc12@ then + return -1 +endi + +sql select bottom(c1, 100), tbname, t1, t2 from select_tags_mt0; +if $rows != 100 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select last_row(c1, c2), tbname, t1, t2 from select_tags_mt0; +if $rows != 1 then + return -1 +endi + +if $data00 != 114 then + return -1 +endi + +print $data01 +if $data01 != 99.00000 then + return -1 +endi + +if $data02 != @select_tags_tb15@ then + return -1 +endi + +if $data03 != 15 then + return -1 +endi + +print ====== selectivity+tags+group by tags======================= +sql select first(c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +if $rows != 16 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +print $data01 +if $data01 != @select_tags_tb0@ then + return -1 +endi + +if $data11 != @select_tags_tb1@ then + return -1 +endi + +if $data02 != 0 then + return -1 +endi + +if $data03 != @abc0@ then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +sql select last_row(ts,c1), tbname, t1, t2 from select_tags_mt0 group by tbname; +if $rows != 16 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.799@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:50.800@ then + return -1 +endi + +print $data01 +if $data01 != 99 then + return -1 +endi + +if $data11 != 100 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select tbname,t1,t2 from select_tags_mt0; +if $row != 16 then + return -1 +endi + +if $data00 != @select_tags_tb0@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data10 != @select_tags_tb1@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @abc1@ then + return -1 +endi + +sql select tbname,ts from select_tags_mt0; +if $row != 12800 then + return -1 +endi + +if $data00 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @select_tags_tb0@ then + return -1 +endi + +if $data01 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data11 != @70-01-01 08:01:40.001@ then + return -1 +endi + +sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname; +if $row != 200 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.087@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.088@ then + return -1 +endi + +if $data20 != @70-01-01 08:01:40.089@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.096@ then + return -1 +endi + +if $data01 != 87 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2; +if $row != 4 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.099@ then + return -1 +endi + +if $data01 != 99 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.199@ then + return -1 +endi + +if $data11 != 99 then + return -1 +endi + +if $data12 != @abc0@ then + return -1 +endi + +if $data13 != @select_tags_tb0@ then + return -1 +endi + +if $data14 != @abc0@ then + return -1 +endi + +if $data20 != @70-01-01 08:01:50.100@ then + return -1 +endi + +if $data21 != 100 then + return -1 +endi + +if $data22 != @abc1@ then + return -1 +endi + +if $data23 != @select_tags_tb1@ then + return -1 +endi + +if $data24 != @abc1@ then + return -1 +endi + +if $data30 != @70-01-01 08:01:50.200@ then + return -1 +endi + +if $data31 != 100 then + return -1 +endi + +if $data32 != @abc1@ then + return -1 +endi + +if $data33 != @select_tags_tb1@ then + return -1 +endi + +if $data34 != @abc1@ then + return -1 +endi + + +# slimit /limit +sql select top(c1, 2), t2 from select_tags_mt0 where tbname in ('select_tags_tb0', 'select_tags_tb1') group by tbname,t2 limit 2 offset 1; +if $row != 2 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.199@ then + return -1 +endi + +if $data01 != 99 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data04 != @abc0@ then + return -1 +endi + +print ======= selectivity + tags + group by + tags + filter =========================== +sql select first(c1), t1 from select_tags_mt0 where c1<=2 group by tbname; +if $row != 3 then + return -1 +endi + +if $data00 != 0 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != 1 then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @select_tags_tb1@ then + return -1 +endi + +if $data20 != 2 then + return -1 +endi + +if $data21 != 2 then + return -1 +endi + +if $data22 != @select_tags_tb2@ then + return -1 +endi + +sql select first(c1), tbname from select_tags_mt0 where c1<=2 interval(1s); +if $row != 3 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:50.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @select_tags_tb1@ then + return -1 +endi + +if $data20 != @70-01-01 08:02:00.000@ then + return -1 +endi + +if $data21 != 2 then + return -1 +endi + +if $data22 != @select_tags_tb2@ then + return -1 +endi + +sql select first(ts),ts from select_tags_tb0 where c1<3 +if $row != 1 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +sql select last(ts),ts from select_tags_tb0 where c1<3 +if $row != 1 then + return -1 +endi + +if $data00 != $data01 then + return -1 +endi + +print ======= selectivity + tags + group by + tags + filter + interval ================ +sql select first(c1), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 3 then + return -1 +endi + +if $data00 != @70-01-01 00:00:00.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +if $data05 != @select_tags_tb0@ then + return -1 +endi + +if $data15 != @select_tags_tb1@ then + return -1 +endi + +if $data25 != @select_tags_tb2@ then + return -1 +endi + +sql select top(c1, 5), t2 from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 15 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.002@ then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != @select_tags_tb0@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:50.402@ then + return -1 +endi + +if $data91 != 2 then + return -1 +endi + +if $data92 != @abc1@ then + return -1 +endi + +if $data93 != @select_tags_tb1@ then + return -1 +endi + +#if data +sql select top(c1, 50), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +if $row != 48 then + return -1 +endi + +if $data00 != @70-01-01 08:01:40.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != @abc0@ then + return -1 +endi + +if $data03 != 0 then + return -1 +endi + +if $data04 != @select_tags_tb0@ then + return -1 +endi + +if $data05 != @select_tags_tb0@ then + return -1 +endi + +if $data10 != @70-01-01 08:01:40.001@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != @abc0@ then + return -1 +endi + +if $data13 != 0 then + return -1 +endi + +if $data14 != @select_tags_tb0@ then + return -1 +endi + +if $data15 != @select_tags_tb0@ then + return -1 +endi + +if $data90 != @70-01-01 08:01:40.300@ then + return -1 +endi + +if $data91 != 0 then + return -1 +endi + +if $data92 != @abc0@ then + return -1 +endi + +if $data93 != 0 then + return -1 +endi + +if $data94 != @select_tags_tb0@ then + return -1 +endi + +if $data95 != @select_tags_tb0@ then + return -1 +endi + +sql select last(ts),TBNAME from select_tags_mt0 interval(1y) +if $row != 1 then + return -1 +endi + +print ======= selectivity + tags+ group by + tags + filter + interval + join=========== + + +print ======error sql============================================= +sql_error select first(*), tbname from select_tags_mt0; +sql_error select first(ts), first(c1),tbname from select_tags_mt0; +sql_error select first(ts), last(ts), tbname from select_tags_mt0; +sql_error select last_row(*), first(ts), tbname, t1, t2 from select_tags_mt0; +sql_error select tbname, last_row(*), t1, first(ts) from select_tags_mt0; +sql_error select first(ts), tbname from select_tags_tb0; +sql_error select last_row(*), t1 from select_tags_tb0; +sql_error select count(*), tbname from select_tags_mt0; +sql_error select sum(c2), tbname from select_tags_mt0; +sql_error select avg(c3), tbname from select_tags_mt0; +sql_error select percentile(c3, 50), tbname from select_tags_mt0; +sql_error select apercentile(c4, 50), tbname from select_tags_mt0; +sql_error select spread(c2), tbname, t1 from select_tags_mt0; +sql_error select stddev(c2), tbname from select_tags_mt0; +sql_error select twa(c2), tbname from select_tags_mt0; +sql_error select interp(c2), tbname from select_tags_mt0 where ts=100001; + +sql_error select t1,t2,tbname from select_tags_mt0 group by tbname; +sql_error select count(tbname) from select_tags_mt0 interval(1d); +sql_error select count(tbname) from select_tags_mt0 group by t1; +sql_error select count(tbname),SUM(T1) from select_tags_mt0 interval(1d); +sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 where c1<=2 interval(1d) group by tbname; +sql_error select ts from select_tags_mt0 interval(1y); +sql_error select count(*), tbname from select_tags_mt0 interval(1y); +sql_error select tbname, t1 from select_tags_mt0 interval(1y); + +#===error sql + group by =============================================== +#valid sql: select first(c1), last(c2), tbname from select_tags_mt0 group by tbname; +#valid sql: select first(c1), last(c2), count(*), tbname from select_tags_mt0 group by tbname; +#valid sql: select first(c1), last(c2), count(*) from select_tags_mt0 group by tbname, t1; +#valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2; + +sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname; +sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname; +sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname; +# this sql is valid: select first(c1), t2 from select_tags_mt0 group by tbname; + +#sql select first(ts), tbname from select_tags_mt0 group by tbname; +#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; +#sql select count(*),tbname from select_tags_mt0 group by tbname diff --git a/tests/script/general/parser/set_tag_vals.sim b/tests/script/general/parser/set_tag_vals.sim new file mode 100644 index 0000000000..8076643247 --- /dev/null +++ b/tests/script/general/parser/set_tag_vals.sim @@ -0,0 +1,227 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = db +$tbPrefix = tb +$stbPrefix = stb +$tbNum = 1000 +$rowNum = 100 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== alter_tg.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(9), t2 binary(8)) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'usr . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $tgstr , $tgstr1 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +sleep 2000 + +sql show tables +if $rows != $tbNum then + return -1 +endi + +print ================== alter table add tags +sql alter table $stb add tag t3 int +sql alter table $stb add tag t4 binary(60) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb (ts, c1) values (now-100a, $i ) + sql alter table $tb set tag t3 = $i + sql insert into $tb (ts, c1) values (now, $i ) + sql alter table $tb set tag t4 = $i + $i = $i + 1 +endw + +print ================== all tags have been changed! +sql select tbname from $stb where t3 = 'NULL' +if $rows != 0 then + return -1 +endi + +print ================== set tag to null +sql create table stb1_tg (ts timestamp, c1 int) tags(t1 int,t2 bigint,t3 double,t4 float,t5 smallint,t6 tinyint) +sql create table stb2_tg (ts timestamp, c1 int) tags(t1 bool,t2 binary(10), t3 nchar(10)) +sql create table tb1_tg1 using stb1_tg tags(1,2,3,4,5,6) +sql create table tb1_tg2 using stb2_tg tags(true, 'tb1_tg2', '表1标签2') +sql insert into tb1_tg1 values (now,1) +sql insert into tb1_tg2 values (now,1) + +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.000000000 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql select * from stb2_tg +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != tb1_tg2 then + return -1 +endi +if $data04 != 表1标签2 then + return -1 +endi + +sql alter table tb1_tg1 set tag t1 = -1 +sql alter table tb1_tg1 set tag t2 = -2 +sql alter table tb1_tg1 set tag t3 = -3 +sql alter table tb1_tg1 set tag t4 = -4 +sql alter table tb1_tg1 set tag t5 = -5 +sql alter table tb1_tg1 set tag t6 = -6 +sql alter table tb1_tg2 set tag t1 = false +sql alter table tb1_tg2 set tag t2 = 'binary2' +sql alter table tb1_tg2 set tag t3 = '涛æ€' +sql reset query cache +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data02 != -1 then + return -1 +endi +if $data03 != -2 then + return -1 +endi +if $data04 != -3.000000000 then + return -1 +endi +if $data05 != -4.00000 then + return -1 +endi +if $data06 != -5 then + return -1 +endi +if $data07 != -6 then + return -1 +endi +sql select * from stb2_tg +if $data02 != 0 then + return -1 +endi +if $data03 != binary2 then + return -1 +endi +if $data04 != æ¶›æ€ then + return -1 +endi + +sql alter table tb1_tg1 set tag t1 = NULL +sql alter table tb1_tg1 set tag t2 = NULL +sql alter table tb1_tg1 set tag t3 = NULL +sql alter table tb1_tg1 set tag t4 = NULL +sql alter table tb1_tg1 set tag t5 = NULL +sql alter table tb1_tg1 set tag t6 = NULL +sql alter table tb1_tg2 set tag t1 = NULL +sql alter table tb1_tg2 set tag t2 = NULL +sql alter table tb1_tg2 set tag t3 = NULL +sql reset query cache +sql select * from stb1_tg +if $rows != 1 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi +sql select * from stb2_tg +if $data02 != null then + return -1 +endi + +print $data03 +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/general/parser/single_row_in_tb.sim new file mode 100644 index 0000000000..bf94c71347 --- /dev/null +++ b/tests/script/general/parser/single_row_in_tb.sim @@ -0,0 +1,38 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$stbPrefix = sr_stb +$ts0 = 1537146000000 +print ========== single_row_in_tb.sim +$db = $dbPrefix +$stb = $stbPrefix + +sql drop database if exists $db +sql create database $db rows 200 tables 4 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) + +$i = 0 +$ts = $ts0 +$tb1 = $tbPrefix . 1 +sql create table $tb1 using $stb tags( 1 ) +sql insert into $tb1 values ( $ts0 , 1, 2, 3, 4, true, 'binay10', '涛æ€nchar10' ) +print ====== tables created + +run lite/parser/single_row_in_tb_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/single_row_in_tb_query.sim diff --git a/tests/script/general/parser/single_row_in_tb_query.sim b/tests/script/general/parser/single_row_in_tb_query.sim new file mode 100644 index 0000000000..7bab49f224 --- /dev/null +++ b/tests/script/general/parser/single_row_in_tb_query.sim @@ -0,0 +1,194 @@ +sleep 3000 +sql connect + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$stbPrefix = sr_stb +$ts0 = 1537146000000 +print ========== single_row_in_tb_query.sim +$db = $dbPrefix +$stb = $stbPrefix + +sql use $db +$tb1 = $tbPrefix . 1 + +sql select first(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select last(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c1) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c2) from $stb where ts >= $ts0 and ts < now group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi + +sql select first(ts, c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select last(ts, c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c1) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select first(ts, c1), last(c2) from $tb1 where ts >= $ts0 and ts < now +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi + +#### query a STable and using where clause +sql select first(ts,c1), last(ts,c1), spread(c1) from $stb where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(c1), last(c1) from $stb where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' interval(1d) group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 00:00:00.000@ then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + +sql select max(c1), min(c1), sum(c1), avg(c1), count(c1) from $stb where c1 > 0 group by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 1.000000000 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +sql select first(ts,c1), last(ts,c1) from $tb1 where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' interval(1d) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 00:00:00.000@ then + return -1 +endi +if $data01 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data04 != 1 then + return -1 +endi diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim new file mode 100644 index 0000000000..ae83d92e22 --- /dev/null +++ b/tests/script/general/parser/slimit.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = slm_db +$tbPrefix = slm_tb +$stbPrefix = slm_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== slimit.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +sql create database $db rows 200 cache 1024 tblocks 200 tables 4 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + $t2 = $i + $t3 = $i + $t4 = 'æ¶›æ€ . $tb + $t4 = $t4 . ' + $t5 = $i + $t6 = true + sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = '涛æ€nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + $ts = $ts + $delta + sql insert into $tb values ( $ts , null, null, null, null, null, null, null, null, null ) + $i = $i + 1 +endw +print ====== $db tables created + +$db = $dbPrefix . 1 +sql drop database if exists $db +sql create database $db rows 200 cache 1024 +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + $t2 = $i + $t3 = $i + $t4 = 'æ¶›æ€ . $tb + $t4 = $t4 . ' + $t5 = $i + $t6 = true + sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , null , null , null , null , null , null , null , null , null ) + $x = $x + 1 + endw + $i = $i + 1 +endw +print ====== $db tables created + +run lite/parser/slimit_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/slimit_query.sim diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim new file mode 100644 index 0000000000..40be5c1b91 --- /dev/null +++ b/tests/script/general/parser/slimit1.sim @@ -0,0 +1,66 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit_alter_tag.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db rows 200 +sql use $db + +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) +# If grouped by t2, some groups should have tables from different vnodes +sql create table tb0 using stb tags (0, 0) +sql create table tb1 using stb tags (1, 0) +sql create table tb2 using stb tags (2, 0) +sql create table tb3 using stb tags (3, 1) +sql create table tb4 using stb tags (4, 1) +sql create table tb5 using stb tags (5, 1) +sql create table tb6 using stb tags (6, 2) +sql create table tb7 using stb tags (7, 2) +sql create table tb8 using stb tags (8, 2) +# tb9 is intentionally set the same tags with tb8 +sql create table tb9 using stb tags (8, 2) + +$i = 0 +$tbNum = 10 +while $i < $tbNum + $tb = tb . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c1 = $x * 10 + $c1 = $c1 + $i + sql insert into $tb values ( $ts , $c1 , $c1 , $c1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ================== tables and data created + +run lite/parser/slimit1_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/slimit1_query.sim diff --git a/tests/script/general/parser/slimit1_query.sim b/tests/script/general/parser/slimit1_query.sim new file mode 100644 index 0000000000..617ccb3fd9 --- /dev/null +++ b/tests/script/general/parser/slimit1_query.sim @@ -0,0 +1,184 @@ +sleep 3000 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit1_query.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql use $db + +#### group by t2,t1 + slimit +sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 6 +if $rows != 3 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 6 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 7 then + return -1 +endi +$res = 2 * $rowNum +if $data20 != $res then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +## desc +sql select count(*) from stb group by t2,t1 order by t2 desc slimit 5 soffset 0 +if $rows != 5 then + return -1 +endi +$res = 2 * $rowNum +if $data00 != $res then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data12 != 7 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data21 != 2 then + return -1 +endi +if $data22 != 6 then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != 5 then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 4 then + return -1 +endi + +### empty result set +#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 0 soffset 0 +#if $rows != 0 then +# return -1 +#endi +#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 10 +#if $rows != 0 then +# return -1 +#endi + +#### group by t2 + slimit +sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 0 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data10 != $res then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 0 +if $rows != 2 then + return -1 +endi +$res = 4 * $rowNum +if $data00 != $res then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +$res = 4 * $rowNum +if $data10 != $res then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 1 +if $rows != 2 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data10 != $res then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data11 != 0 then + return -1 +endi + diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim new file mode 100644 index 0000000000..6091fa89b4 --- /dev/null +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -0,0 +1,257 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = slm_alt_tg_db + +print ========== slimit_alter_tag.sim +# make sure the data in each table crosses a file block boundary +$rowNum = 300 +$ts0 = 1537146000000 +$delta = 600000 +$db = $dbPrefix + +sql drop database if exists $db +sql create database $db rows 200 +sql use $db + +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) +# If grouped by t2, some groups should have tables from different vnodes +sql create table tb0 using stb tags (0, 0) +sql create table tb1 using stb tags (1, 0) +sql create table tb2 using stb tags (2, 0) +sql create table tb3 using stb tags (3, 1) +sql create table tb4 using stb tags (4, 1) +sql create table tb5 using stb tags (5, 1) +sql create table tb6 using stb tags (6, 2) +sql create table tb7 using stb tags (7, 2) +sql create table tb8 using stb tags (8, 2) +# tb9 is intentionally set the same tags with tb8 +sql create table tb9 using stb tags (8, 2) + +$i = 0 +$tbNum = 10 +while $i < $tbNum + $tb = tb . $i + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c1 = $x * 10 + $c1 = $c1 + $i + sql insert into $tb values ( $ts , $c1 , $c1 , $c1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print ================== tables and data created + +print ================== add a tag +sql alter table stb add tag tg_added binary(15) +sql describe stb +if $rows != 7 then + return -1 +endi +if $data60 != tg_added then + return -1 +endi + +sql select count(*) from stb group by tg_added order by tg_added asc +if $rows != 1 then + return -1 +endi +$res = $rowNum * 10 +if $data00 != $res then + return -1 +endi +#if $data01 != NULL then +# return -1 +#endi + +print ================== change tag values +$i = 0 +while $i < 10 + $tb = tb . $i + $tg_added = ' . $tb + $tg_added = $tg_added . ' + sql alter table $tb set tag tg_added = $tg_added + $i = $i + 1 +endw +sql describe tb0 +if $rows != 7 then + return -1 +endi +if $data63 != tb0 then + return -1 +endi + +sleep 2000 +sql reset query cache +sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3 +if $rows != 5 then + print ===== result: $rows + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data02 != tb3 then + return -1 +endi +if $data12 != tb4 then + return -1 +endi +if $data22 != tb5 then + return -1 +endi +if $data32 != tb6 then + return -1 +endi +if $data42 != tb7 then + return -1 +endi + +sql alter table tb9 set tag t2 = 3 +sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1 +if $rows != 3 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data01 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +if $data11 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data15 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data25 != 3 then + return -1 +endi + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +sql use $db +### repeat above queries +sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3; +if $rows != 5 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data30 != $rowNum then + return -1 +endi +if $data40 != $rowNum then + return -1 +endi +if $data02 != tb3 then + return -1 +endi +if $data12 != tb4 then + return -1 +endi +if $data22 != tb5 then + return -1 +endi +if $data32 != tb6 then + return -1 +endi +if $data42 != tb7 then + return -1 +endi + +sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1 +if $rows != 3 then + return -1 +endi +$res = 3 * $rowNum +if $data00 != $res then + return -1 +endi +if $data01 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data05 != 1 then + return -1 +endi +$res = 3 * $rowNum +if $data10 != $res then + return -1 +endi +if $data11 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data15 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data25 != 3 then + return -1 +endi + +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi diff --git a/tests/script/general/parser/slimit_query.sim b/tests/script/general/parser/slimit_query.sim new file mode 100644 index 0000000000..7735b1b84b --- /dev/null +++ b/tests/script/general/parser/slimit_query.sim @@ -0,0 +1,572 @@ +sleep 3000 +sql connect + +$dbPrefix = slm_db +$tbPrefix = slm_tb +$stbPrefix = slm_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== slimit_stb.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +##### select from supertable + +### illegal operations +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 limit 1 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu soffset 5 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 soffset 1 +#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 +#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 +#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1 + +### select from stb + group by + slimit offset +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 slimit 5 soffset 0 +if $rows != 5 then + return -1 +endi +#if $data08 != NULL then +#if $data08 != 涛æ€nchar9 then +# return -1 +#endi +$res = $tbPrefix . 0 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 1 +if $data19 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data49 != $res then + return -1 +endi + +#sql reset query cache +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 5 +if $rows != 5 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 0 +print res = $res +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data49 != $res then + return -1 +endi + +## asc +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 1 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 4 +if $data39 != $res then + return -1 +endi +## desc +sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 desc slimit 4 soffset 1 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 8 +if $data09 != $res then + return -1 +endi +$res = $tbPrefix . 5 +if $data39 != $res then + return -1 +endi + +### limit + slimit +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 0 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 2 offset 1 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 asc slimit 4 soffset 1 limit 1 offset 0 +if $rows != 4 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 1 +if $data08 != $res then + return -1 +endi +print data09 = $data09 +if $data09 != 1 then + return -1 +endi +$res = $tbPrefix . 4 +if $data38 != $res then + return -1 +endi +if $data39 != 4 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 desc slimit 4 soffset 1 limit 1 offset 0 +if $rows != 4 then + return -1 +endi +$res = $tbPrefix . 8 +if $data08 != $res then + return -1 +endi +if $data09 != 8 then + return -1 +endi +$res = $tbPrefix . 5 +if $data38 != $res then + return -1 +endi +if $data39 != 5 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 group by t1,t2,t3 order by t1 asc slimit 3 soffset 1 limit 1 offset 0 +if $rows != 3 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +$res = $tbPrefix . 3 +if $data08 != $res then + return -1 +endi +if $data09 != 3 then + return -1 +endi +$res = $tbPrefix . 4 +if $data18 != $res then + return -1 +endi +if $data19 != 4 then + return -1 +endi +$res = $tbPrefix . 5 +if $data28 != $res then + return -1 +endi +if $data29 != 5 then + return -1 +endi + +### slimit + fill +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 0 offset 0 +if $rows != 0 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0 +print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0 +print $rows $data00 $data01 $data02 $data03 +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data09 != slm_tb6 then + return -1 +endi +if $data10 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -2.000000000 then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data19 != slm_tb6 then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data29 != slm_tb7 then + return -1 +endi +if $data30 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data36 != -2 then + return -1 +endi +if $data39 != slm_tb7 then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data49 != slm_tb8 then + return -1 +endi +if $data50 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data59 != slm_tb8 then + return -1 +endi +if $data69 != slm_tb9 then + return -1 +endi +if $data79 != slm_tb9 then + return -1 +endi +# desc +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 desc slimit 4 soffset 4 limit 2 offset 0 +if $rows != 8 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data09 != slm_tb5 then + return -1 +endi +if $data10 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data11 != -1 then + return -1 +endi +if $data12 != -2 then + return -1 +endi +if $data13 != -2.000000000 then + return -1 +endi +if $data17 != null then + return -1 +endi +if $data18 != null then + return -1 +endi +if $data19 != slm_tb5 then + return -1 +endi +if $data20 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data29 != slm_tb4 then + return -1 +endi +if $data30 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data31 != -1 then + return -1 +endi +if $data36 != -2 then + return -1 +endi +if $data39 != slm_tb4 then + return -1 +endi +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data49 != slm_tb3 then + return -1 +endi +if $data50 != @18-09-17 09:05:00.000@ then + return -1 +endi +if $data59 != slm_tb3 then + return -1 +endi +if $data69 != slm_tb2 then + return -1 +endi +if $data79 != slm_tb2 then + return -1 +endi + +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 asc slimit 4 soffset 4 limit 2 offset 598 +if $rows != 4 then + return -1 +endi +if $data00 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data09 != slm_tb6 then + return -1 +endi +if $data10 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data12 != 9 then + return -1 +endi +if $data13 != 9.000000000 then + return -1 +endi +if $data19 != slm_tb7 then + return -1 +endi +if $data20 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data24 != 9.000000000 then + return -1 +endi +if $data29 != slm_tb8 then + return -1 +endi +if $data30 != @18-09-19 10:50:00.000@ then + return -1 +endi +if $data35 != 9 then + return -1 +endi +if $data36 != 1 then + return -1 +endi +if $data37 != binary9 then + return -1 +endi +if $data38 != 涛æ€nchar9 then + return -1 +endi +if $data39 != slm_tb9 then + return -1 +endi + +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != $tbNum then + return -1 +endi +$res = $rowNum + 1 +if $data00 != $res then + return -1 +endi +if $data90 != $res then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛æ€slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +$res = $rowNum + 1 +if $data60 != $res then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != 10 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛æ€slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +## [TBASE-604] +#sql_error select count(tbname) from slm_stb0 group by t1 +#sql show databases + +## [TBASE-605] +sql_error select * from slm_stb0 where t2 >= 2 and t3 <= 9 group by tbname slimit 40 limit 1; + + +################################################## +# slm_db1 is a database that contains the exactly the same +# schema as slm_db0, but all records in slm_db1 contains +# only NULL values. +$db = $dbPrefix . 1 +sql use $db + +### +sql select count(*) from $stb +if $rows != 1 then + return -1 +endi +if $data00 != $totalNum then + return -1 +endi + +sql select count(c1) from $stb +if $rows != 0 then + return -1 +endi + +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 asc +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb0 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data23 != 2 then + return -1 +endi +if $data34 != 涛æ€slm_tb3 then + return -1 +endi +if $data45 != 4.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb7 then + return -1 +endi +sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data90 != $rowNum then + return -1 +endi +if $data01 != slm_tb9 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data23 != 7 then + return -1 +endi +if $data34 != 涛æ€slm_tb6 then + return -1 +endi +if $data45 != 5.000000000 then + return -1 +endi +if $data56 != 1 then + return -1 +endi +if $data60 != $rowNum then + return -1 +endi +if $data71 != slm_tb2 then + return -1 +endi + +sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/parser/stream.sim b/tests/script/general/parser/stream.sim new file mode 100644 index 0000000000..33a7d2ac6e --- /dev/null +++ b/tests/script/general/parser/stream.sim @@ -0,0 +1,223 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 5 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 5 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +print ======================== stream.sim +sleep 2000 +$db = strm_db +$tb = tb +$mt = mt +$strm = strm +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== set up DB +$i = 0 + +sql drop database if exists $db +sql create database $db +sql use $db + + +## [TBASE300] +print ====== TBASE-300 +sql create table mt (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table tb1 using mt tags(1) +sql create table tb2 using mt tags(2) +sql create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2),first(c1), last(c2) from mt interval(4s) sliding(2s) +sleep 10000 +sql insert into tb2 values(now,1,1) +sql insert into tb1 values(now,1,1) +sleep 4000 +sql select * from mt +sql select * from strm +sql drop table tb1 +sleep 10000 +sql select * from strm +if $rows != 2 then + if $rows != 1 then + return -1 + endi +endi +sql drop table tb2 +sql drop table mt +sql drop table strm + +## [TBASE304] +print ====== TBASE-304 +sleep 10000 +print create mt +sql create table mt (ts timestamp, c1 int) tags(t1 int, t2 int) +print create tb1 +sql create table tb1 using mt tags(1, 1) +print create tb2 +sql create table tb2 using mt tags(1, -1) +print create strm +sql create table strm as select count(*), avg(c1) from mt where t2 >= 0 interval(4s) sliding(2s) +sql insert into tb1 values (now,1) +sql insert into tb2 values (now,2) +sleep 20000 +sql select * from strm; +sleep 1000 +if $rows != 2 then + print ==== expect rows = 2, actually returned rows = $rows + return -1 +endi +if $data01 != 1 then + return -1 +endi +print data02 = $data02 +if $data02 != 1.000000000 then + return -1 +endi +sql alter table mt drop tag t2; +sql insert into tb2 values (now,2); +sql insert into tb1 values (now,1); +sql select * from strm; +sql alter table mt add tag t2 int; +sleep 10000 +sql select * from strm + +print ================= create a stream with a wildcard filter on tags of a STable +sql drop database $db +sql create database $db +sql use $db +sql create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10)) +sql create table tb1 using stb tags('a1') +sql create table tb2 using stb tags('b2') +sql create table tb3 using stb tags('a3') +sql create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s) +sleep 11000 +sql insert into tb1 values (now, 0, 'tb1') +sleep 4000 +sql insert into tb2 values (now, 2, 'tb2') +sleep 4000 +sql insert into tb3 values (now, 0, 'tb3') +sleep 6000 + +sql describe strm +if $rows == 0 then + return -1 +endi + +sql select * from strm +sleep 1000 +print ======== data0: $data00 $data01 $data02 $data03 +print ======== data1: $data10 $data11 $data12 $data13 +print ======== data2: $data20 $data21 $data22 $data23 +print ======== data3: $data30 $data31 $data32 $data33 +if $rows != 4 then + print ==== expect rows = 4, actually returned rows = $rows + return -1 +endi +if $data02 != 0.000000000 then + return -1 +endi +if $data03 == tb2 then + return -1 +endi +if $data13 == tb2 then + return -1 +endi +if $data23 == tb2 then + return -1 +endi +if $data33 == tb2 then + return -1 +endi + +## The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. But the current refreshing frequency is every 10 min +## commented out the case below to save running time +sql create table tb4 using stb tags('a4') +sleep 6000 +sql insert into tb4 values(now, 4, 'tb4') +sleep 10000 +sql select * from strm order by ts desc +sleep 1000 +print ======== data0: $data00 $data01 $data02 $data03 +#print ======== data1: $data10 $data11 $data12 $data13 +#print ======== data2: $data20 $data21 $data22 $data23 +#print ======== data3: $data30 $data31 $data32 $data33 +if $rows != 6 then + print ==== expect rows = 6, actually returned rows = $rows + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != tb4 then + return -1 +endi + +print =============== change tag values to see if stream still works correctly +sql alter table tb4 set tag t1='b4' +sleep 3000 # waiting for new tag valid +sql insert into tb1 values (now, 1, 'tb1_a1') +sleep 4000 +sql insert into tb4 values (now, -4, 'tb4_b4') +sleep 10000 +sql select * from strm order by ts desc +sleep 1000 +print ======== data0: $data00 $data01 $data02 $data03 +#print ======== data1: $data10 $data11 $data12 $data13 +#print ======== data2: $data20 $data21 $data22 $data23 +#print ======== data3: $data30 $data31 $data32 $data33 +if $rows != 8 then + print ==== expect rows = 8, actually returned rows = $rows + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != tb1_a1 then + return -1 +endi + +sql drop database if exists $db +sql drop database if exists strm_db_0 +sql create database strm_db_0 +sql use strm_db_0 + +sql create table stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(15), c6 nchar(15), c7 bool) tags(t1 int, t2 binary(15)) +sql create table tb0 using stb tags(0, 'tb0') +sql create table tb1 using stb tags(1, 'tb1') +sql create table tb2 using stb tags(2, 'tb2') +sql create table tb3 using stb tags(3, 'tb3') +sql create table tb4 using stb tags(4, 'tb4') + +sql create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb where ts < now + 30s interval(4s) sliding(2s) +sleep 10000 +sql insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛æ€0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛æ€1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛æ€2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛æ€3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛æ€4', true) +sleep 5000 +sql select * from strm0 order by ts desc +sleep 1000 +if $rows != 2 then + print ==== expect rows = 2, actually returned rows = $rows + return -1 +endi + +sql insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛æ€0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛æ€1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛æ€2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛æ€3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛æ€4', true) +sleep 5000 +sql select * from strm0 order by ts desc +sleep 1000 +if $rows != 4 then + print ==== expect rows = 4, actually returned rows = $rows + return -1 +endi + +sql drop database if exists strm_db_0 +sql show databases +if $rows != 0 then + return -1 +endi + +sql create database $db +sql use $db +sql create table stb (ts timestamp, c1 int) tags(t1 int) +sql create table tb1 using stb tags(1) diff --git a/tests/script/general/parser/stream_on_sys.sim b/tests/script/general/parser/stream_on_sys.sim new file mode 100644 index 0000000000..d0f6cbace3 --- /dev/null +++ b/tests/script/general/parser/stream_on_sys.sim @@ -0,0 +1,60 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ======================== stream_on_sys.sim + +$db = log +$tb = tb +$mt = mt +$strm = strm +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +$i = 0 + +sql use $db + +sql create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sql create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sql create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sql create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sql create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sql create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn_192_168_0_1 interval(4s) sliding(2s) +sleep 20000 +sql select * from cpustrm +if $rows <= 0 then + return -1 +endi + +sql select * from memstrm +if $rows <= 0 then + return -1 +endi + +sql select * from diskstrm +if $rows <= 0 then + return -1 +endi + +sql select * from bandstrm +if $rows <= 0 then + return -1 +endi + +sql select * from reqstrm +if $rows <= 0 then + return -1 +endi + +sql select * from iostrm +if $rows <= 0 then + return -1 +endi diff --git a/tests/script/general/parser/tags_dynamically_specifiy.sim b/tests/script/general/parser/tags_dynamically_specifiy.sim new file mode 100644 index 0000000000..b34ea90413 --- /dev/null +++ b/tests/script/general/parser/tags_dynamically_specifiy.sim @@ -0,0 +1,58 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +sleep 3000 + +$db = dytag_db +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== tags_dynamically_specify.sim +$i = 0 + +sql drop database if exists $db +sql create database $db +sql use $db + +sql create table stb (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) + +sql insert into tb1 using stb (t1) tags ('tag1') values ( now + 1s, 'binary1', 1, 1.1) +sql insert into tb2 using stb (t2) tags (2) values ( now + 2s, 'binary2', 2, 2.2) +sql insert into tb3 using stb (t3) tags (3.3) values ( now + 3s, 'binary3', 3, 3.3) + +sql insert into tb4 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4) +sql insert into tb5 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11) values ( now + 5s, 'binary5', 5.5) + +sql select * from stb order by ts asc +if $rows != 5 then + return -1 +endi + + + +sql create table stbx (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float) +sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.9) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9) + +sql select * from stbx +if $rows != 3 then + return -1 +endi + +if $data04 != tag100 then + return -1 +endi + +if $data05 != 100 then + return -1 +endi + +#if $data06 != 100.90000 then +# print "expect: 100.90000, act: $data06" +# return -1 +#endi \ No newline at end of file diff --git a/tests/script/general/parser/tags_filter.sim b/tests/script/general/parser/tags_filter.sim new file mode 100644 index 0000000000..29b295b6cd --- /dev/null +++ b/tests/script/general/parser/tags_filter.sim @@ -0,0 +1,106 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$db = tf_db +$tbNum = 10 +$rowNum = 5 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== tags_filter.sim +$i = 0 + +sql drop database if exists $db +sql create database $db +sql use $db +##### filter tags that contains special characters +sql create table stb (ts timestamp, c1 int) tags (t1 binary(10)) +sql create table tb1 using stb tags('*') +sql create table tb2 using stb tags('%') +sql create table tb3 using stb tags('') +sql create table tb4 using stb tags('/'') + +sql insert into tb1 values ( $ts0 , 1) +sql insert into tb2 values ( $ts0 , 2) +sql insert into tb3 values ( $ts0 , 3) +sql insert into tb4 values ( $ts0 , 4) + +sql select * from stb where t1 = '*' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from stb where t1 = '%' +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql select * from stb where t1 = '' +if $rows != 1 then + return -1 +endi +if $data01 != 3 then + return -1 +endi + +sql select * from stb where t1 = '/'' +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from stb where t1 like '*' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql_error select * from stb where t1 > 1 +sql_error select * from stb where t1 > '1' +sql_error select * from stb where t1 > 'a' + +## wildcard '%' +#sql select * from stb where t1 like '%' +#if $rows != 1 then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi + +sql select * from stb where t1 like '' +if $rows != 1 then + return -1 +endi +if $data01 != 3 then + return -1 +endi + +sql select * from stb where t1 like '/'' +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/parser/tbnameIn.sim b/tests/script/general/parser/tbnameIn.sim new file mode 100644 index 0000000000..d3b16ea202 --- /dev/null +++ b/tests/script/general/parser/tbnameIn.sim @@ -0,0 +1,75 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ti_db +$tbPrefix = ti_tb +$stbPrefix = ti_stb +$tbNum = 2000 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== tbnameIn.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int, t2 nchar(20), t3 binary(20), t4 bigint, t5 smallint, t6 double) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $halfNum + $i1 = $i + $halfNum + $tb = $tbPrefix . $i + $tb1 = $tbPrefix . $i1 + $tgstr = 'tb . $i + $tgstr = $tgstr . ' + $tgstr1 = 'tb . $i1 + $tgstr1 = $tgstr1 . ' + sql create table $tb using $stb tags( $i , $tgstr , $tgstr , $i , $i , $i ) + sql create table $tb1 using $stb tags( $i1 , $tgstr1 , $tgstr1 , $i , $i , $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) + sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw +print ====== tables created + +run lite/parser/tbnameIn_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +run lite/parser/tbnameIn_query.sim diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/general/parser/tbnameIn_query.sim new file mode 100644 index 0000000000..37cc1aa824 --- /dev/null +++ b/tests/script/general/parser/tbnameIn_query.sim @@ -0,0 +1,433 @@ +sleep 3000 +sql connect + +$dbPrefix = ti_db +$tbPrefix = ti_tb +$stbPrefix = ti_stb +$tbNum = 2000 +$rowNum = 10 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +print ========== tbnameIn_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i +$tb = $tbPrefix . 0 +print ====== use db +sql use $db + +#### tbname in + other tag filtering +## [TBASE-362] +# tbname in + tag filtering is allowed now!!! +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and t1 > 2 + +# tbname in used on meter +sql_error select count(*) from $tb where tbname in ('ti_tb1', 'ti_tb300') + +## tbname in + group by tag +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') group by t1 order by t1 asc +if $rows != 2 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 300 then + return -1 +endi + +## duplicated tbnames +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb1', 'ti_tb1', 'ti_tb2', 'ti_tb2', 'ti_tb3') group by t1 order by t1 asc +if $rows != 3 then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != $rowNum then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != $rowNum then + return -1 +endi +if $data21 != 3 then + return -1 +endi + +## wrong tbnames +sql select count(*) from $stb where tbname in ('tbname in', 'ti_tb1', 'ti_stb0') group by t1 order by t1 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +## tbname in + colummn filtering +sql select count(*) from $stb where tbname in ('tbname in', 'ti_tb1', 'ti_stb0', 'ti_tb2') and c8 like 'binary%' group by t1 order by t1 asc +if $rows != 2 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 10 then + return -1 +endi +if $data11 != 2 then + return -1 +endi + +# multiple tbname in is not allowed NOW +sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc +#if $rows != 4 then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != 1 then +# return -1 +#endi +#if $data10 != $rowNum then +# return -1 +#endi +#if $data11 != 5 then +# return -1 +#endi +#if $data20 != $rowNum then +# return -1 +#endi +#if $data21 != 300 then +# return -1 +#endi +#if $data30 != $rowNum then +# return -1 +#endi +#if $data31 != 1000 then +# return -1 +#endi + +#### aggregation on stb with 6 tags + where + group by + limit offset +#$val1 = 1 +#$val2 = $tbNum - 1 +#sql select count(*) from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 +#$val = $tbNum - 3 +#if $rows != $val then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi +#if $data02 != tb2 then +# return -1 +#endi +#if $data03 != tb2 then +# return -1 +#endi +#if $data04 != 2 then +# return -1 +#endi +#if $data05 != 2 then +# return -1 +#endi +# +#sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 0 +#if $rows != 2 then +# return -1 +#endi +#if $data00 != $rowNum then +# return -1 +#endi +#if $data01 != tb4 then +# return -1 +#endi +#if $data02 != 4 then +# return -1 +#endi +#if $data11 != tb3 then +# return -1 +#endi +#if $data12 != 3 then +# return -1 +#endi +#sql select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1 +#if $rows != 0 then +# return -1 +#sql_error select count(*) from $stb where t1 like 1 +# +###### aggregation on tb + where + fill + limit offset +#sql select max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit 10 offset 1 +#if $rows != 10 then +# return -1 +#endi +#if $data00 != @18-09-17 09:05:00.000@ then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data11 != 1 then +# return -1 +#endi +#if $data90 != @18-09-17 09:50:00.000@ then +# return -1 +#endi +#if $data91 != 5 then +# return -1 +#endi +# +#$tb5 = $tbPrefix . 5 +#sql select max(c1), min(c2) from $tb5 where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4) limit 10 offset 1 +#if $rows != 10 then +# return -1 +#endi +#if $data00 != @18-09-17 09:05:00.000@ then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data02 != -2 then +# return -1 +#endi +#if $data11 != 1 then +# return -1 +#endi +#if $data12 != -2 then +# return -1 +#endi +#if $data90 != @18-09-17 09:50:00.000@ then +# return -1 +#endi +#if $data91 != 5 then +# return -1 +#endi +#if $data92 != -2 then +# return -1 +#endi +# +#### [TBASE-350] +### tb + interval + fill(value) + limit offset +#$tb = $tbPrefix . 0 +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data11 != -1 then +# return -1 +#endi +# +## tb + interval + fill(linear) + limit offset +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(linear) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 0 then +# return -1 +#endi +#if $data11 != 0 then +# return -1 +#endi +#if $data13 != 0.500000000 then +# return -1 +#endi +#if $data35 != 0.000000000 then +# return -1 +#endi +#if $data46 != 0.000000000 then +# return -1 +#endi +#if $data47 != true then +# return -1 +#endi +#if $data57 != NULL then +# return -1 +#endi +#if $data68 != binary3 then +# return -1 +#endi +#if $data79 != NULL then +# return -1 +#endi +# +### tb + interval + fill(prev) + limit offset +#$limit = $rowNum +#$offset = $limit / 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(prev) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +# +# +#$limit = $rowNum +#$offset = $limit / 2 +#$offset = $offset + 10 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != $limit then +# return -1 +#endi +#if $data01 != 5 then +# return -1 +#endi +#if $data02 != 5 then +# return -1 +#endi +#if $data03 != 5.000000000 then +# return -1 +#endi +#if $data04 != 5.000000000 then +# return -1 +#endi +#if $data05 != 0.000000000 then +# return -1 +#endi +#if $data07 != true then +# return -1 +#endi +#if $data08 != binary5 then +# return -1 +#endi +#if $data09 != nchar5 then +# return -1 +#endi +#if $data18 != NULL then +# return -1 +#endi +#if $data19 != NULL then +# return -1 +#endi +#if $data16 != -2.000000000 then +# return -1 +#endi +#if $data17 != true then +# return -1 +#endi +#if $data11 != -1 then +# return -1 +#endi +# +#$limit = $rowNum +#$offset = $limit * 2 +#$offset = $offset - 11 +#sql select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 = 5 interval(5m) fill(value, -1, -2) limit $limit offset $offset +#if $rows != 10 then +# return -1 +#endi +#if $data01 != -1 then +# return -1 +#endi +#if $data02 != -2 then +# return -1 +#endi +#if $data11 != 5 then +# return -1 +#endi +#if $data12 != 5 then +# return -1 +#endi +#if $data13 != 5.000000000 then +# return -1 +#endi +#if $data15 != 0.000000000 then +# return -1 +#endi +#if $data16 != 0.000000000 then +# return -1 +#endi +#if $data18 != binary5 then +# return -1 +#endi +#if $data19 != nchar5 then +# return -1 +#endi +#if $data27 != true then +# return -1 +#endi +#if $data38 != NULL then +# return -1 +#endi +#if $data49 != NULL then +# return -1 +#endi +# +#### [TBASE-350] +### stb + interval + fill + group by + limit offset +#sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10 +#if $rows != 20 then +# return -1 +#endi +# +#$limit = 5 +#$offset = $rowNum * 2 +#$offset = $offset - 2 +#sql select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2) group by t1 order by t1 limit $limit offset $offset +#if $rows != $tbNum then +# return -1 +#endi +#if $data00 != @18-11-25 19:30:00.000@ then +# return -1 +#endi +#if $data01 != 9 then +# return -1 +#endi +#if $data12 != -2 then +# return -1 +#endi +#if $data23 != 9.000000000 then +# return -1 +#endi +#if $data34 != -2.000000000 then +# return -1 +#endi +#if $data45 != true then +# return -1 +#endi +#if $data56 != binary9 then +# return -1 +#endi +#if $data68 != 3 then +# return -1 +#endi +#if $data72 != 9 then +# return -1 +#endi +#if $data84 != 9.000000000 then +# return -1 +#endi +#if $data98 != 0 then +# return -1 +#endi diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim new file mode 100644 index 0000000000..12b1631821 --- /dev/null +++ b/tests/script/general/parser/testSuite.sim @@ -0,0 +1,92 @@ +run lite/parser/alter.sim +sleep 2000 +run lite/parser/alter1.sim +sleep 2000 +run lite/parser/alter_stable.sim +sleep 2000 +run lite/parser/auto_create_tb.sim +sleep 2000 +run lite/parser/auto_create_tb_drop_tb.sim +sleep 2000 +run lite/parser/col_arithmetic_operation.sim +sleep 2000 +run lite/parser/columnValue.sim +sleep 2000 +run lite/parser/commit.sim +run lite/parser/create_db.sim +sleep 2000 +run lite/parser/create_mt.sim +sleep 2000 +run lite/parser/create_tb.sim +sleep 2000 +run lite/parser/dbtbnameValidate.sim +sleep 2000 +run lite/parser/fill.sim +sleep 2000 +run lite/parser/fill_stb.sim +sleep 2000 +run lite/parser/first_last.sim +sleep 2000 +run lite/parser/import_commit1.sim +sleep 2000 +run lite/parser/import_commit2.sim +sleep 2000 +run lite/parser/import_commit3.sim +sleep 2000 +run lite/parser/import_file.sim +sleep 2000 +run lite/parser/insert_tb.sim +sleep 2000 +run lite/parser/tags_dynamically_specifiy.sim +sleep 2000 +run lite/parser/interp.sim +run lite/parser/lastrow.sim +sleep 2000 +run lite/parser/limit.sim +sleep 2000 +run lite/parser/limit1.sim +sleep 2000 +run lite/parser/limit1_tblocks100.sim +sleep 2000 +run lite/parser/limit2.sim +sleep 2000 +run lite/parser/mixed_blocks.sim +sleep 2000 +run lite/parser/nchar.sim +sleep 2000 +run lite/parser/null_char.sim +sleep 2000 +run lite/parser/selectResNum.sim +sleep 2000 +run lite/parser/select_across_vnodes.sim +sleep 2000 +run lite/parser/select_from_cache_disk.sim +sleep 2000 +run lite/parser/set_tag_vals.sim +sleep 2000 +run lite/parser/single_row_in_tb.sim +sleep 2000 +run lite/parser/slimit.sim +sleep 2000 +run lite/parser/slimit1.sim +sleep 2000 +run lite/parser/slimit_alter_tags.sim +sleep 2000 +run lite/parser/stream_on_sys.sim +sleep 2000 +run lite/parser/stream.sim +sleep 2000 +run lite/parser/tbnameIn.sim +sleep 2000 +run lite/parser/where.sim +sleep 2000 +#run lite/parser/repeatAlter.sim +sleep 2000 +#run lite/parser/repeatStream.sim +sleep 2000 +run lite/parser/join.sim +run lite/parser/join_multivnode.sim +run lite/parser/projection_limit_offset.sim +sleep 2000 +run lite/parser/select_with_tags.sim +run lite/parser/groupby.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim new file mode 100644 index 0000000000..edc03fc4f0 --- /dev/null +++ b/tests/script/general/parser/timestamp.sim @@ -0,0 +1,67 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$dbPrefix = ts_db +$tbPrefix = ts_tb +$stbPrefix = ts_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== timestamp.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +sql drop database if exists $db +sql create database $db rows 200 cache 1024 tblocks 200 tables 4 +print ====== create tables +sql use $db +sql create table $stb (ts timestamp, c1 timestamp, c2 int) tags(t1 binary(20)) + +$i = 0 +$ts = $ts0 +$halfNum = $tbNum / 2 +while $i < $tbNum + $tb = $tbPrefix . $i + $t1 = ' . $tb + $t1 = $t1 . ' + sql create table $tb using $stb tags( $t1 ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + $binary = binary . $c + $nchar = '涛æ€nchar . $c + $nchar = $nchar . ' + sql insert into $tb values ( $ts , $ts , $c ) + $x = $x + 1 + endw + $ts = $ts + $delta + sql insert into $tb values ( $ts , null, null ) + $i = $i + 1 +endw +print ====== $db tables created + +run lite/parser/timestamp_query.sim + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed +sql connect +sleep 3000 + +run lite/parser/timestamp_query.sim diff --git a/tests/script/general/parser/timestamp_query.sim b/tests/script/general/parser/timestamp_query.sim new file mode 100644 index 0000000000..63e40d0bf7 --- /dev/null +++ b/tests/script/general/parser/timestamp_query.sim @@ -0,0 +1,33 @@ +sleep 3000 +sql connect + +$dbPrefix = ts_db +$tbPrefix = ts_tb +$stbPrefix = ts_stb +$tbNum = 10 +$rowNum = 300 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== timestamp_query.sim +$i = 0 +$db = $dbPrefix . $i +$stb = $stbPrefix . $i + +print ====== use db +sql use $db + +$tsu = $rowNum * $delta +$tsu = $tsu - $delta +$tsu = $tsu + $ts0 + +##### select from supertable + +$tb = $tbPrefix . 0 +sql select first(c1), last(c1) from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, -1) +$res = $rowNum * 2 +$res = $res - 1 +if $rows != $res then + return -1 +endi + diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim new file mode 100644 index 0000000000..397ce53477 --- /dev/null +++ b/tests/script/general/parser/where.sim @@ -0,0 +1,274 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = wh_db +$tbPrefix = wh_tb +$mtPrefix = wh_mt +$tbNum = 10 +$rowNum = 10000 +$totalNum = $tbNum * $rowNum + +print =============== where.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exits $db -x step1 +step1: +sql create database if not exists $db tables 4 +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + $binary = 'binary . $c + $binary = $binary . ' + $nchar = 'nchar . $c + $nchar = $nchar . ' + sql insert into $tb values (now + $ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +$i = 1 +$tb = $tbPrefix . $i + +## +sql_error select * from $tb where c7 + +# TBASE-654 : invalid filter expression cause server crashed +sql_error select count(*) from $tb where c1<10 and c1<>2 + +sql select * from $tb where c7 = false +$val = $rowNum / 100 +if $rows != $val then + return -1 +endi +sql select * from $mt where c7 = false +$val = $totalNum / 100 +if $rows != $val then + return -1 +endi + +sql select tbname from $mt +if $rows != $tbNum then + return -1 +endi + +sql select tbname from $mt where t1 < 2 +if $rows != 2 then + return -1 +endi +$tb = $tbPrefix . 0 +if $data00 != $tb then + return -1 +endi +$tb = $tbPrefix . 1 +if $data10 != $tb then + return -1 +endi + +## select specified columns + +sql select c1 from $mt +if $rows != $totalNum then + return -1 +endi +sql select count(c1) from $mt +if $data00 != $totalNum then + return -1 +endi + +sql select c1 from $mt where c1 >= 0 +if $rows != $totalNum then + return -1 +endi +sql select count(c1) from $mt where c1 <> -1 +if $data00 != $totalNum then + return -1 +endi +sql select count(c1) from $mt where c1 <> -1 group by t1 +if $rows != $tbNum then + return -1 +endi +if $data00 != $rowNum then + return -1 +endi + + +## like +sql_error select * from $mt where c1 like 1 +#sql_error select * from $mt where t1 like 1 + +## [TBASE-593] +sql create table wh_mt1 (ts timestamp, c1 smallint, c2 int, c3 bigint, c4 float, c5 double, c6 tinyint, c7 binary(10), c8 nchar(10), c9 bool, c10 timestamp) tags (t1 binary(10), t2 smallint, t3 int, t4 bigint, t5 float, t6 double) +sql create table wh_mt1_tb1 using wh_mt1 tags ('tb11', 1, 1, 1, 1, 1) +sql insert into wh_mt1_tb1 values (now, 1, 1, 1, 1, 1, 1, 'binary', 'nchar', true, '2019-01-01 00:00:00.000') +sql_error select last(*) from wh_mt1 where c1 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c1 in ('1') +sql_error select last(*) from wh_mt1 where c2 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c2 in ('1') +sql_error select last(*) from wh_mt1 where c3 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c3 in ('1') +sql_error select last(*) from wh_mt1 where c4 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c4 in ('1') +sql_error select last(*) from wh_mt1 where c5 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c5 in ('1') +sql_error select last(*) from wh_mt1 where c6 in ('1') +sql_error select last(*) from wh_mt1_tb1 where c6 in ('1') +sql_error select last(*) from wh_mt1 where c7 in ('binary') +sql_error select last(*) from wh_mt1_tb1 where c7 in ('binary') +sql_error select last(*) from wh_mt1 where c8 in ('nchar') +sql_error select last(*) from wh_mt1_tb1 where c9 in (true, false) +sql_error select last(*) from wh_mt1 where c10 in ('2019-01-01 00:00:00.000') +sql_error select last(*) from wh_mt1_tb1 where c10 in ('2019-01-01 00:00:00.000') +sql_error select last(*) from wh_mt1 where t1 in ('binary') +sql_error select last(*) from wh_mt1 where t2 in (1) +sql_error select last(*) from wh_mt1 where t3 in (1) +sql_error select last(*) from wh_mt1 where t4 in (1) +sql_error select last(*) from wh_mt1 where t5 in (1) +sql_error select last(*) from wh_mt1 where t6 in (1) +sql select last(*) from wh_mt1 where c1 = 1 +if $rows != 1 then + return -1 +endi + +## [TBASE-597] +sql create table wh_mt2 (ts timestamp, c1 timestamp, c2 binary(10), c3 nchar(10)) tags (t1 binary(10)) +sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1') + +# 2019-01-01 00:00:00.000 1546272000000 +# 2019-01-01 00:10:00.000 1546272600000 +# 2019-01-01 09:00:00.000 1546304400000 +# 2019-01-01 09:10:00.000 1546305000000 +sql insert into wh_mt2_tb1 values ('2019-01-01 00:00:00.000', '2019-01-01 09:00:00.000', 'binary10', 'nchar10') +sql insert into wh_mt2_tb1 values ('2019-01-01 00:10:00.000', '2019-01-01 09:10:00.000', 'binary10', 'nchar10') +sql select * from wh_mt2_tb1 where c1 > 1546304400000 +if $rows != 1 then + return -1 +endi +if $data00 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000' +if $rows != 1 then + return -1 +endi +if $data00 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > 1546304400000 and ts < '2019-01-01 00:10:00.000' +if $rows != 0 then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 > '2019-01-01 09:00:00.000' and ts < '2019-01-01 00:10:00.000' +if $rows != 0 then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 >= 1546304400000 and c1 <= '2019-01-01 09:10:00.000' +if $rows != 2 then + return -1 +endi +if $data00 != @19-01-01 00:00:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:00:00.000@ then + return -1 +endi +if $data10 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data11 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql select * from wh_mt2_tb1 where c1 >= '2019-01-01 09:00:00.000' and c1 <= '2019-01-01 09:10:00.000' +if $rows != 2 then + return -1 +endi +if $data00 != @19-01-01 00:00:00.000@ then + return -1 +endi +if $data01 != @19-01-01 09:00:00.000@ then + return -1 +endi +if $data10 != @19-01-01 00:10:00.000@ then + return -1 +endi +if $data11 != @19-01-01 09:10:00.000@ then + return -1 +endi + +sql create table tb_where_null (ts timestamp, c1 float, c2 binary(10)) +sql insert into tb_where_null values ('2019-01-01 09:00:00.000', 1, 'val1') +sql insert into tb_where_null values ('2019-01-01 09:00:01.000', NULL, NULL) +sql insert into tb_where_null values ('2019-01-01 09:00:02.000', 2, 'val2') +sql_error select * from tb_where_null where c1 = NULL +sql_error select * from tb_where_null where c1 <> NULL +sql_error select * from tb_where_null where c1 < NULL +sql select * from tb_where_null where c1 = "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_null where c1 <> "NULL" +if $rows != 2 then + return -1 +endi +sql select * from tb_where_null where c1 <> "nulL" +if $rows != 2 then + return -1 +endi + +sql select * from tb_where_null where c1 > "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_null where c1 >= "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_null where c2 = "NULL" +if $rows != 0 then + return -1 +endi + +sql select * from tb_where_null where c2 <> "NULL" +if $rows != 2 then + return -1 +endi +sql select * from tb_where_null where c2 <> "nUll" +if $rows != 2 then + return -1 +endi diff --git a/tests/script/general/stream/metrics_1.sim b/tests/script/general/stream/metrics_1.sim new file mode 100644 index 0000000000..e61572d9f4 --- /dev/null +++ b/tests/script/general/stream/metrics_1.sim @@ -0,0 +1,287 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = m1_db +$tbPrefix = m1_tb +$mtPrefix = m1_mt +$stPrefix = m1_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 0 +$mt = $mtPrefix . $i + +sql select count(*) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +print create table $st as select avg(tbcol) from $mt interval(1d) +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $mt interval(1d) -x step11 + return -1 +step11: + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $mt interval(1d) -x step12 + return -1 +step12: + +print =============== step13 +sql select top(tbcol, 1) from $mt interval(1d) + +print =============== step14 + +sql select bottom(tbcol, 1) from $mt interval(1d) + +print =============== step15 pe + +sql select percentile(tbcol, 1) from $mt interval(1d) -x step15 + return -1 +step15: + +print =============== step16 +sql select diff(tbcol) from $mt interval(1d) -x step16 + return -1 +step16: + +print =============== step17 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step18 as +sql select count(tbcol) from $mt interval(1d) +print ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step19 gb +sql select count(tbcol) from $mt interval(1d) group by tgcol +print ===> $data00 $data01 +if $data01 != 20 then + return -1 +endi + +print =============== step20 x +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) group by tgcol +print ===> $data00 $data01 +if $data01 != 20 then + return -1 +endi + +print =============== step21 +print sleep 22 seconds +sleep 22000 + +print =============== step22 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +#$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/general/stream/metrics_del.sim b/tests/script/general/stream/metrics_del.sim new file mode 100644 index 0000000000..9077d48f45 --- /dev/null +++ b/tests/script/general/stream/metrics_del.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfBlocksPerMeter -v 4 +system sh/cfg.sh -n dnode1 -c pointsPerCompBlock -v 100 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = md_db +$tbPrefix = md_tb +$mtPrefix = md_mt +$stPrefix = md_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +print =============== step3 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw +sql drop table $mt + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != null then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi diff --git a/tests/script/general/stream/metrics_n.sim b/tests/script/general/stream/metrics_n.sim new file mode 100644 index 0000000000..c3b20f8616 --- /dev/null +++ b/tests/script/general/stream/metrics_n.sim @@ -0,0 +1,262 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = mn_db +$tbPrefix = mn_tb +$mtPrefix = mn_mt +$stPrefix = mn_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +print =============== step3 count32 +#total 32 count in select +sql select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $mt interval(1d) + +# total 32 count in stream +$st = $stPrefix . c32 +sql create table $st as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $mt interval(1d) + +print =============== step4 count31 + +#total 31 count in select +sql select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $mt interval(1d) +print ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +# total 31 count in stream will crash, 32 will error +$st = $stPrefix . c31 +sql create table $st as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $mt interval(1d) + +print =============== step5 avg ... +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 1900 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi + +$st = $stPrefix . avg +sql create table $st as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) + +print =============== step6 others +sql select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from $mt interval(1d) -x step6 + return -1 +step6: + +$st = $stPrefix . ot +sql create table $st as select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from $mt interval(1d) -x step61 + return -1 +step61: + +print =============== step7 where +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1d) +print select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 1900 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi +if $data07 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step8 as +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 1900 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi +if $data07 != 200 then + return -1 +endi + +$st = $stPrefix . as +#sql create table $st as select avg(tbcol) as a1, sum(tbcol) as a2, min(tbcol) as a3, max(tbcol) as a4, first(tbcol) as a5, last(tbcol) as a6, count(tbcol) as a7, avg(tbcol) as a8, sum(tbcol) as a9, min(tbcol) as a3, max(tbcol) as a4, first(tbcol) as a5, last(tbcol) as a6, count(tbcol) as a7 from $mt where ts < now + 4m interval(1d) + +print =============== step9 +print sleep 22 seconds +sleep 22000 + +print =============== step10 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +$st = $stPrefix . c31 +sql select * from $st +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi +if $data04 != 200 then + return -1 +endi +if $data05 != 200 then + return -1 +endi +if $data06 != 200 then + return -1 +endi +if $data07 != 200 then + return -1 +endi +if $data08 != 200 then + return -1 +endi +if $data09 != 200 then + return -1 +endi + + + +$st = $stPrefix . avg +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 1900 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi + diff --git a/tests/script/general/stream/metrics_replica1_vnoden.sim b/tests/script/general/stream/metrics_replica1_vnoden.sim new file mode 100644 index 0000000000..5129dc2f02 --- /dev/null +++ b/tests/script/general/stream/metrics_replica1_vnoden.sim @@ -0,0 +1,245 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = m1v_db +$tbPrefix = m1v_tb +$mtPrefix = m1v_mt +$stPrefix = m1v_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 32000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/general/stream/stream_1.sim b/tests/script/general/stream/stream_1.sim new file mode 100644 index 0000000000..0178ef2ac3 --- /dev/null +++ b/tests/script/general/stream/stream_1.sim @@ -0,0 +1,206 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = s1_db +$tbPrefix = s1_tb +$mtPrefix = s1_mt +$stPrefix = s1_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +sql show tables +if $rows != 10 then + return -1 +endi + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 20 then + return -1 +endi +if $data02 != 20 then + return -1 +endi +if $data03 != 20 then + return -1 +endi + +print =============== step4 +sql drop table $st +sql show tables +if $rows != 10 then + return -1 +endi + +print =============== step5 +sql select * from $st -x step4 + return -1 +step4: + +print =============== step6 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step7 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 20 then + return -1 +endi +if $data02 != 20 then + return -1 +endi +if $data03 != 20 then + return -1 +endi + +print =============== step8 +$i = 1 +$st = $stPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +sql show tables +if $rows != 11 then + return -1 +endi + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +sql show tables +if $rows != 12 then + return -1 +endi + +print =============== step9 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +print =============== step10 +sql drop table $st +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step11 +sql select * from $st -x step10 + return -1 +step10: + +print =============== step12 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +sql show tables +if $rows != 12 then + return -1 +endi + +print =============== step13 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + diff --git a/tests/script/general/stream/stream_2.sim b/tests/script/general/stream/stream_2.sim new file mode 100644 index 0000000000..a2af8f8548 --- /dev/null +++ b/tests/script/general/stream/stream_2.sim @@ -0,0 +1,194 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = s2_db +$tbPrefix = s2_tb +$mtPrefix = s2_mt +$stPrefix = s2_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi + +sql show tables +if $rows != 10 then + return -1 +endi + +sql create table $st as select count(tbcol) from $tb interval(1d) + +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 20 then + return -1 +endi + +print =============== step4 +sql drop table $st +sql show tables +if $rows != 10 then + return -1 +endi + +print =============== step5 +sql select * from $st -x step4 + return -1 +step4: + +print =============== step6 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step7 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 +if $data01 != 20 then + return -1 +endi +if $data02 != 20 then + return -1 +endi +if $data03 != 20 then + return -1 +endi + +print =============== step8 +$i = 1 +$st = $stPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +sql show tables +if $rows != 11 then + return -1 +endi + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $mt interval(1d) + +sql show tables +if $rows != 12 then + return -1 +endi + +print =============== step9 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != 200 then + return -1 +endi +if $data03 != 200 then + return -1 +endi + +print =============== step10 +sql drop table $st +sql show tables +if $rows != 11 then + return -1 +endi + +print =============== step11 +sql select * from $st -x step10 + return -1 +step10: + +print =============== step12 +sql create table $st as select count(tbcol) from $mt interval(1d) + +sql show tables +if $rows != 12 then + return -1 +endi + +print =============== step13 +print sleep 22 seconds +sleep 22000 +sql select * from $st +print select * from $st => $data01 $data02, $data03 +if $data01 != 200 then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi + diff --git a/tests/script/general/stream/stream_3.sim b/tests/script/general/stream/stream_3.sim new file mode 100644 index 0000000000..6758d74aba --- /dev/null +++ b/tests/script/general/stream/stream_3.sim @@ -0,0 +1,204 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = s3_db +$tbPrefix = s3_tb +$mtPrefix = s3_mt +$stPrefix = s3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 +print sleep 22 seconds +sleep 22000 + +print =============== step6 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step7 + +system sh/exec.sh -n dnode1 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfBlocksPerMeter -v 4 +system sh/cfg.sh -n dnode1 -c pointsPerCompBlock -v 100 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/exec.sh -n dnode1 -s start + +sleep 4000 +print ======================== dnode1 start + +$dbPrefix = stst3db +$tbPrefix = stst3tb +$mtPrefix = stst3mt +$stPrefix = stst3st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step8 +step8: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step9 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +#$st = $stPrefix . c3 +#sql select * from $st -x step11 +# print ===> select * from $st first time should be error +# return -1 +#step11: + +print =============== step12 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + + diff --git a/tests/script/general/stream/stream_restart.sim b/tests/script/general/stream/stream_restart.sim new file mode 100644 index 0000000000..6d9324b69c --- /dev/null +++ b/tests/script/general/stream/stream_restart.sim @@ -0,0 +1,142 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = sr_db +$tbPrefix = sr_tb +$mtPrefix = sr_mt +$stPrefix = sr_st +$tbNum = 10 +$rowNum = 200 +$totalNum = 200 + +print =============== step1 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +sleep 2000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 1000 +system sh/exec.sh -n dnode1 -s start + +print =============== step4 +print sleep 23 seconds +sleep 23000 + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print $tb ==> $rows $data00 $data01 +if $rows != $rowNum then + return -1 +endi + +print =============== step6 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 +if $rows <= 1 then + return -1 +endi + + diff --git a/tests/script/general/stream/table_1.sim b/tests/script/general/stream/table_1.sim new file mode 100644 index 0000000000..08aa4912e3 --- /dev/null +++ b/tests/script/general/stream/table_1.sim @@ -0,0 +1,317 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = t1_db +$tbPrefix = t1_tb +$mtPrefix = t1_mt +$stPrefix = t1_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 +sql select top(tbcol, 1) from $tb interval(1d) + +print =============== step14 +sql select bottom(tbcol, 1) from $tb interval(1d) + +print =============== step15 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step16 +sql select diff(tbcol) from $tb interval(1d) -x step16 + return -1 +step16: + +print =============== step17 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step18 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step19 gb +sql select count(tbcol) from $tb interval(1d) group by tgcol -x step19 + return -1 +step19: + +print =============== step20 x +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) group by tgcol -x step20 + return -1 +step20: + +print =============== step21 +print sleep 22 seconds +sleep 22000 + +print =============== step22 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +#$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/general/stream/table_del.sim b/tests/script/general/stream/table_del.sim new file mode 100644 index 0000000000..509c72e4c8 --- /dev/null +++ b/tests/script/general/stream/table_del.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfBlocksPerMeter -v 4 +system sh/cfg.sh -n dnode1 -c pointsPerCompBlock -v 100 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 1024 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = td_db +$tbPrefix = td_tb +$mtPrefix = td_mt +$stPrefix = td_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +print =============== step3 +sql drop table $tb + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != null then + return -1 +endi +if $data02 != null then + return -1 +endi +if $data03 != null then + return -1 +endi diff --git a/tests/script/general/stream/table_n.sim b/tests/script/general/stream/table_n.sim new file mode 100644 index 0000000000..3eeadd0aff --- /dev/null +++ b/tests/script/general/stream/table_n.sim @@ -0,0 +1,291 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = tn_db +$tbPrefix = tn_tb +$mtPrefix = tn_mt +$stPrefix = tn_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c3 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +print =============== step3 count32 +#total 32 count in select +sql select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $tb interval(1d) + +# total 32 count in stream +$st = $stPrefix . c32 +sql create table $st as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $tb interval(1d) + +print =============== step4 count31 + +#total 31 count in select +sql select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $tb interval(1d) +print ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +# total 31 count in stream will crash, 32 will error +$st = $stPrefix . c31 +sql create table $st as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from $tb interval(1d) + +print =============== step5 avg ... +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $tb interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 190 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi + +$st = $stPrefix . avg +sql create table $st as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $tb interval(1d) + +print =============== step6 others +sql select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from $tb interval(1d) +print ===> $data01 $data02 $data03 +if $data01 != 5.766281297 then + return -1 +endi +#if $data02 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi +if $data03 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . ot +sql create table $st as select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from $tb interval(1d) + +print =============== step7 total ... +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from $tb interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 190 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi +if $data07 != 5.766281297 then + return -1 +endi +if $data08 != 0.190000000 then + return -1 +endi +if $data09 != 20 then + return -1 +endi + +$st = $stPrefix . to +sql create table $st as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step8 where +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data09 != 20 then + return -1 +endi + +$st = $stPrefix . wh +sql create table $st as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m interval(1d) + + +print =============== step9 as +sql select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m interval(1d) +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data09 != 20 then + return -1 +endi + +$st = $stPrefix . as +#sql create table $st as select avg(tbcol) as a1, sum(tbcol) as a2, min(tbcol) as a3, max(tbcol) as a4, first(tbcol) as a5, last(tbcol) as a6, stddev(tbcol) as a7, percentile(tbcol, 1) as a8, count(tbcol) as a9, leastsquares(tbcol, 1, 1) as a10 from $tb where ts < now + 4m interval(1d) + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . c31 +sql select * from $st +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +$st = $stPrefix . avg +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 190 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi + +$st = $stPrefix . ot +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 5.766281297 then + return -1 +endi +#if $data02 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi +if $data03 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . to +sql select * from $st +print ===> select * from $st +print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data01 != 9.500000000 then + return -1 +endi +if $data02 != 190 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 19 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 19 then + return -1 +endi +if $data07 != 5.766281297 then + return -1 +endi +if $data08 != 0.190000000 then + return -1 +endi +if $data09 != 20 then + return -1 +endi diff --git a/tests/script/general/stream/table_replica1_vnoden.sim b/tests/script/general/stream/table_replica1_vnoden.sim new file mode 100644 index 0000000000..f9db9fd9f4 --- /dev/null +++ b/tests/script/general/stream/table_replica1_vnoden.sim @@ -0,0 +1,299 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = t1v_db +$tbPrefix = t1v_tb +$mtPrefix = t1v_mt +$stPrefix = t1v_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . st +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . st +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/general/stream/testSuite.sim b/tests/script/general/stream/testSuite.sim new file mode 100644 index 0000000000..cda88dc826 --- /dev/null +++ b/tests/script/general/stream/testSuite.sim @@ -0,0 +1,12 @@ +run lite/stream/stream_1.sim +run lite/stream/stream_2.sim +run lite/stream/stream_3.sim +run lite/stream/stream_restart.sim +run lite/stream/table_1.sim +run lite/stream/metrics_1.sim +run lite/stream/table_n.sim +run lite/stream/metrics_n.sim +run lite/stream/table_del.sim +run lite/stream/metrics_del.sim +run lite/stream/table_replica1_vnoden.sim +run lite/stream/metrics_replica1_vnoden.sim \ No newline at end of file diff --git a/tests/script/general/table/back_insert.sim b/tests/script/general/table/back_insert.sim new file mode 100644 index 0000000000..43831cca95 --- /dev/null +++ b/tests/script/general/table/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/general/table/bigint.sim b/tests/script/general/table/bigint.sim new file mode 100644 index 0000000000..667ce523cb --- /dev/null +++ b/tests/script/general/table/bigint.sim @@ -0,0 +1,73 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_bi_db +$tbPrefix = lm_bi_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed bigint) + +#sql insert into $tb values (now, -9223372036854775809) +sql insert into $tb values (now, -9223372036854770000) +sql select * from $tb +if $rows != 1 then + return -1 +endi +#if $data01 != -9223372036854775808 then +if $data01 != -9223372036854770000 then + return -1 +endi + +print =============== step2 +#sql insert into $tb values (now+1a, -9223372036854775808) +sql insert into $tb values (now+1a, -9223372036854770000) +sql select * from $tb +if $rows != 2 then + return -1 +endi +#if $data01 != -9223372036854775808 then +if $data01 != -9223372036854770000 then + return -1 +endi + +print =============== step3 +#sql insert into $tb values (now+1a, 9223372036854775807) +sql insert into $tb values (now+2a, 9223372036854770000) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +#if $data01 != 9223372036854775807 then +if $data01 != 9223372036854770000 then + return -1 +endi + +print =============== step4 +#sql insert into $tb values (now+1a, 9223372036854775808) +sql insert into $tb values (now+3a, 9223372036854770000) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +#if $data01 != 9223372036854775807 then +if $data01 != 9223372036854770000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/binary.sim b/tests/script/general/table/binary.sim new file mode 100644 index 0000000000..bc91c48c19 --- /dev/null +++ b/tests/script/general/table/binary.sim @@ -0,0 +1,63 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_bn_db +$tbPrefix = lm_bn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed binary(5)) + +sql insert into $tb values (now, ) -x step1 + return -1 +step1: + +print =============== step2 +sql insert into $tb values (now+1a, '1234') +sql select speed from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, '23456') +sql select speed from $tb order by ts desc +if $rows != 2 then + return -1 +endi +print ==> $data00 +if $data00 != 23456 then + return -1 +endi + +print =============== step4 +sql_error insert into $tb values (now+3a, '345678') +sql insert into $tb values (now+3a, '34567') +sql select speed from $tb order by ts desc +if $rows != 3 then + return -1 +endi +print ==> $data00 +if $data00 != 34567 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/bool.sim b/tests/script/general/table/bool.sim new file mode 100644 index 0000000000..1393315b4f --- /dev/null +++ b/tests/script/general/table/bool.sim @@ -0,0 +1,92 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_bo_db +$tbPrefix = lm_bo_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +$x = 0 +sql create table $tb (ts timestamp, speed bool) + +sql insert into $tb values (now, true) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, 1) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 0) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4m, -1) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5m, false) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/column2.sim b/tests/script/general/table/column2.sim new file mode 100644 index 0000000000..3d32ae454e --- /dev/null +++ b/tests/script/general/table/column2.sim @@ -0,0 +1,26 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print =============== step1 +sql create database db +sql use db +sql create table tt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g timestamp, h binary(10), i bool); +sql insert into tt values (now + 1m , 1 , 1 , 1 , 1 , 1 , 10, 150000000 , '11' , true ) + +sql select * from tt +if $rows != 1 then + return -1 +endi + +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/table/column_name.sim b/tests/script/general/table/column_name.sim new file mode 100644 index 0000000000..c49e58336d --- /dev/null +++ b/tests/script/general/table/column_name.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_cm_db +$tbPrefix = lm_cm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table $tb(ts timestamp, int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, s int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) +sql drop table $tb + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql insert into $tb values (now , 1) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/general/table/column_num.sim b/tests/script/general/table/column_num.sim new file mode 100644 index 0000000000..5e124a1943 --- /dev/null +++ b/tests/script/general/table/column_num.sim @@ -0,0 +1,85 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_cn_db +$tbPrefix = lm_cn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb() -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp) -x step2 + return -1 +step2: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts int) -x step3 + return -1 +step3: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql insert into $tb values (now, 1 , 2 , 3 , 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) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/column_value.sim b/tests/script/general/table/column_value.sim new file mode 100644 index 0000000000..bb811b7ab8 --- /dev/null +++ b/tests/script/general/table/column_value.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_cv_db +$tbPrefix = lm_cv_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+1a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, speed bigint, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -x step2 + return -1 +step2: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, speed float, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now+2a, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+3a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/general/table/date.sim b/tests/script/general/table/date.sim new file mode 100644 index 0000000000..52242b6388 --- /dev/null +++ b/tests/script/general/table/date.sim @@ -0,0 +1,90 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_da_db +$tbPrefix = lm_da_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) +sql insert into $tb values ('2017-01-01 08:00:00.001', 1) +sql select ts from $tb +if $rows != 1 then + return -1 +endi +if $data00 != @17-01-01 08:00:00.001@ then + return -1 +endi + +print =============== step2 +sql insert into $tb values ('2017-08-28 00:23:46.429+ 1a', 2) +#sql insert into $tb values ('2017-08-28 00:23:46cd .429', 2) +sql select ts from $tb +if $rows != 2 then + return -1 +endi + +print =============== step3 +#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) +#sql insert into $tb values ('1970-01-01 08:00:00.000', 3) +sql select ts from $tb +if $rows != 2 then + return -1 +endi + +print =============== step4 +sql insert into $tb values(now, 4); +sql insert into $tb values(now+1a, 5); +sql insert into $tb values(now+1s, 6); +sql insert into $tb values(now+1m, 7); +sql insert into $tb values(now+1h, 8); +sql insert into $tb values(now+1d, 9); +sql_error insert into $tb values(now+3w, 10); +sql_error insert into $tb values(now+1n, 11); +sql_error insert into $tb values(now+1y, 12); + +print =============== step5 +sql_error insert into $tb values ('9999-12-31 213:59:59.999', 13) +sql select ts from $tb +print $rows +if $rows != 8 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values ('9999-12-99 23:59:59.999', 13) + +sql select ts from $tb +if $rows != 8 then + return -1 +endi + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, ts2 timestamp) + +print =============== step8 +sql insert into $tb values (now, now) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/db.table.sim b/tests/script/general/table/db.table.sim new file mode 100644 index 0000000000..242f778a15 --- /dev/null +++ b/tests/script/general/table/db.table.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_dt_db +$tbPrefix = lm_dt_tb +$db = $dbPrefix +$tb = $tbPrefix + +print =============== step1 +sql create database $db +$table = lm_dt_db.lm_dt_tb + +print =============== step2 +sql create table $table (ts timestamp, speed int) + +print =============== step3 +sql insert into $table values (now, 1) + +print =============== step4 +sql select * from $table +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step5 +sql describe $table + +print =============== step6 +sql drop table $table + + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/table/delete_reuse1.sim b/tests/script/general/table/delete_reuse1.sim new file mode 100644 index 0000000000..1f47088c6f --- /dev/null +++ b/tests/script/general/table/delete_reuse1.sim @@ -0,0 +1,89 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database d1 replica 1 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop table d1.t1 +sleep 1000 +sql insert into d1.t1 values(now, 2) -x step2 + return -1 +step2: + +print ========= step3 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print ========= step4 +$x = 0 +while $x < 20 + + sql drop table d1.t1 + sleep 1000 + sql insert into d1.t1 values(now, -1) -x step4 + return -1 + step4: + + sql create table d1.t1 (ts timestamp, i int) + sql insert into d1.t1 values(now, $x ) + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + if $data01 != $x then + return -1 + endi + + $x = $x + 1 + + print ===> loop times: $x +endw diff --git a/tests/script/general/table/delete_reuse2.sim b/tests/script/general/table/delete_reuse2.sim new file mode 100644 index 0000000000..acd69bc488 --- /dev/null +++ b/tests/script/general/table/delete_reuse2.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======== step1 +sql create database db1 replica 1 +sql create table db1.t1 (ts timestamp, i int) +sql insert into db1.t1 values(now, 1) + +sql select * from db1.t1 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql drop table db1.t1 +sleep 1000 +sql_error insert into db1.t1 values(now, 2) + +print ========= step3 +sql create table db1.tb1 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 2) +sql select * from db1.tb1 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql use db1 +print ========= step4 +$x = 1 +while $x < 20 + + $tb = tb . $x + sql drop table $tb + + sleep 1000 + sql_error insert into $tb values(now, -1) + + step4: + + $x = $x + 1 + $tb = tb . $x + + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + sql select * from $tb + if $rows != 1 then + return -1 + endi + if $data01 != $x then + return -1 + endi + + print ===> loop times: $x +endw diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/general/table/delete_writing.sim new file mode 100644 index 0000000000..769207b83c --- /dev/null +++ b/tests/script/general/table/delete_writing.sim @@ -0,0 +1,59 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +sql create database db +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) + +print ======== start back +run_back lite/table/back_insert.sim +sleep 1000 + +print ======== step1 +$x = 1 +while $x < 20 + + print drop table times $x + sql drop table db.tb -x step1 + step1: + + sql create table db.tb (ts timestamp, i int) + + sleep 3000 + + $x = $x + 1 +endw diff --git a/tests/script/general/table/describe.sim b/tests/script/general/table/describe.sim new file mode 100644 index 0000000000..1905a0b032 --- /dev/null +++ b/tests/script/general/table/describe.sim @@ -0,0 +1,50 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = de_in_db +$tbPrefix = de_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +sql describe $tb +if $rows != 2 then + return -1 +endi +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data02 != 8 then + return -1 +endi +if $data10 != speed then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data12 != 4 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + \ No newline at end of file diff --git a/tests/script/general/table/double.sim b/tests/script/general/table/double.sim new file mode 100644 index 0000000000..2b34f5a191 --- /dev/null +++ b/tests/script/general/table/double.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_do_db +$tbPrefix = lm_do_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed double) +#sql insert into $tb values (now, -1.79E+308) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 1.79E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.850000000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.400000000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step51 + return -1 +step51: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values(now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values(now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/float.sim b/tests/script/general/table/float.sim new file mode 100644 index 0000000000..95666f677b --- /dev/null +++ b/tests/script/general/table/float.sim @@ -0,0 +1,98 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_fl_db +$tbPrefix = lm_fl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed float) +#sql insert into $tb values (now, -3.40E+38) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 3.40E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.85000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.40000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step5 + return -1 +step5: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.00000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values (now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values (now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/table/int.sim b/tests/script/general/table/int.sim new file mode 100644 index 0000000000..70a2ac767d --- /dev/null +++ b/tests/script/general/table/int.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_in_db +$tbPrefix = lm_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -2147483648) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2147483647) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 2147483648) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step8 +sql insert into $tb values (now+8m, "null") +sql select * from $tb order by ts desc +if $rows != 8 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step9 +sql insert into $tb values (now+9m, 'null') +sql select * from $tb order by ts desc +if $rows != 9 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step10 +sql insert into $tb values (now+10m, -123) +sql select * from $tb order by ts desc +if $rows != 10 then + return -1 +endi +if $data01 != -123 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/general/table/limit.sim b/tests/script/general/table/limit.sim new file mode 100644 index 0000000000..904a49a2fd --- /dev/null +++ b/tests/script/general/table/limit.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 129 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_tl_db +$tbPrefix = ob_tl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =================== step 0 +sql create database $db tables 129 +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +$N = 256 + +print =================== step 1 +$x = $N +$y = 0 +while $x > $y + $table = a . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 2 then + return -1 +endi + +print =================== step 2 + +$x = $N +$y = 0 +while $x > $y + $table = b . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 4 then + return -1 +endi + +print =================== step 3 + +$x = $N +$y = 0 +while $x > $y + $table = c . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 6 then + return -1 +endi + +print =================== step 4 + +$x = $N +$y = 0 +while $x > $y + $table = d . $x + sql create table $table (ts timestamp, speed int, i float, d double, b bigint, c binary(20)) + $x = $x - 1 +endw + +sql show vgroups +if $rows != 8 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/table/smallint.sim b/tests/script/general/table/smallint.sim new file mode 100644 index 0000000000..0547fbb1b6 --- /dev/null +++ b/tests/script/general/table/smallint.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_sm_db +$tbPrefix = lm_sm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed smallint) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -32768) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 32767) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 32767 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 32768) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + \ No newline at end of file diff --git a/tests/script/general/table/table.sim b/tests/script/general/table/table.sim new file mode 100644 index 0000000000..2c8467b9a3 --- /dev/null +++ b/tests/script/general/table/table.sim @@ -0,0 +1,226 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_tb_db +$tbPrefix = ob_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database $db -x step1 +step1: +sql create database $db + +print =============== step2-3-4 +sql use $db + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step5 +sql show tables +if $rows != 7 then + return -1 +endi + +$i = 1 +while $i < 8 + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6-9 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.00000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step10 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql show tables +if $rows != 7 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, val float, val2 double) +sql show tables +if $rows != 7 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/general/table/table_len.sim b/tests/script/general/table/table_len.sim new file mode 100644 index 0000000000..37c06c515c --- /dev/null +++ b/tests/script/general/table/table_len.sim @@ -0,0 +1,105 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_tb_db +$tbPrefix = lm_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table (ts timestamp, speed int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table a (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table a0123456789 (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a0123456789 +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789 (ts timestamp, speed int) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table a;1 (ts timestamp, speed int) -x step5 + return -1 +step5: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create table a'1 (ts timestamp, speed int) -x step6 + return -1 +step6: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create table (a) (ts timestamp, speed int) -x step7 + return -1 +step7: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create table a.1 (ts timestamp, speed int) -x step8 + return -1 +step8: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/table/testSuite.sim b/tests/script/general/table/testSuite.sim new file mode 100644 index 0000000000..5766dd7507 --- /dev/null +++ b/tests/script/general/table/testSuite.sim @@ -0,0 +1,22 @@ +run lite/table/table.sim +run lite/table/vgroup.sim +run lite/table/limit.sim +run lite/table/table_len.sim +run lite/table/column_num.sim +run lite/table/column2.sim +run lite/table/column_name.sim +run lite/table/column_value.sim +run lite/table/describe.sim +run lite/table/date.sim +run lite/table/bigint.sim +run lite/table/binary.sim +run lite/table/bool.sim +run lite/table/double.sim +run lite/table/float.sim +run lite/table/int.sim +run lite/table/smallint.sim +run lite/table/tinyint.sim +run lite/table/db.table.sim +run lite/table/delete_reuse1.sim +run lite/table/delete_reuse2.sim +run lite/table/delete_writing.sim diff --git a/tests/script/general/table/tinyint.sim b/tests/script/general/table/tinyint.sim new file mode 100644 index 0000000000..4e50b6dba2 --- /dev/null +++ b/tests/script/general/table/tinyint.sim @@ -0,0 +1,104 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$i = 0 +$dbPrefix = lm_ti_db +$tbPrefix = lm_ti_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed tinyint) + +sql insert into $tb values (now, NULL) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, -128) -x step2 + return -1 +step2: +sql insert into $tb values (now+1m, NULL) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 127) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 127 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 128) -x step4 + return -1 +step4: +sql insert into $tb values (now+3m, NULL) +sql select * from $tb +if $rows != 4 then + return -1 +endi +if $data01 != null then + return -1 +endi + +print =============== step5 +sql_error insert into $tb values (now+4m, a2) +sql insert into $tb values (now+4m, 0) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql_error insert into $tb values (now+5m, 2a) +sql insert into $tb values (now+5m, 2) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +print =============== step7 +sql_error insert into $tb values (now+6m, 2a'1) +sql insert into $tb values (now+6m, 2) +sql select * from $tb order by ts desc +if $rows != 7 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/table/vgroup.sim b/tests/script/general/table/vgroup.sim new file mode 100644 index 0000000000..d5198534bc --- /dev/null +++ b/tests/script/general/table/vgroup.sim @@ -0,0 +1,162 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_vg_db +$tbPrefix = ob_vg_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =================== step 1 +sql create database $db tables 4 +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +sql create table table1 (ts timestamp, speed int) +sql create table table2 (ts timestamp, speed int) +sql create table table3 (ts timestamp, speed int) +sql create table table4 (ts timestamp, speed int) +sql show vgroups +if $rows != 1 then + return -1 +endi + +sql create table table5 (ts timestamp, speed int) +sql create table table6 (ts timestamp, speed int) +sql create table table7 (ts timestamp, speed int) +sql create table table8 (ts timestamp, speed int) +sql show vgroups +if $rows != 2 then + return -1 +endi + +sql create table table9 (ts timestamp, speed int) +sql create table table10 (ts timestamp, speed int) +sql create table table11 (ts timestamp, speed int) +sql create table table12 (ts timestamp, speed int) +sql show vgroups +if $rows != 3 then + return -1 +endi + +sql create table table13 (ts timestamp, speed int) +sql show vgroups +if $rows != 4 then + return -1 +endi + +sql drop table table13 +sql show vgroups +if $rows != 3 then + return -1 +endi + +sql create table table13 (ts timestamp, speed int) +sql show vgroups +if $rows != 4 then + return -1 +endi + +print =================== step 2 +$i = 1 +$db = $dbPrefix . $i + +sql create database $db +sql use $db +sql show vgroups +if $rows != 0 then + return -1 +endi + +sql create table table1 (ts timestamp, speed int) -x error2 + return -1 +error2: + +$i = 0 +$db = $dbPrefix . $i +sql drop database $db + +$i = 1 +$db = $dbPrefix . $i +sql use $db +sql create table table2 (ts timestamp, speed int) +sql show vgroups +if $rows != 1 then + return -1 +endi + +sql drop table table2 +sql show vgroups +if $rows != 0 then + return -1 +endi + +sql create table table1 (ts timestamp, speed int) +sql create table table2 (ts timestamp, speed int) +sql create table table3 (ts timestamp, speed int) +sql create table table4 (ts timestamp, speed int) +sql drop table table1 +sql show vgroups +if $rows != 1 then + return -1 +endi + +print =================== step 3 +$i = 0 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table1 (ts timestamp, speed int) + +$i = 2 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table3 (ts timestamp, speed int) + +$i = 3 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table4 (ts timestamp, speed int) + +$i = 4 +$db = $dbPrefix . $i +sql create database $db +sql use $db +sql create table table5 (ts timestamp, speed int) -x error3 + return -1 +error3: + +sql show databases +if $rows != 5 then + return -1 +endi + +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw +sql show databases +if $rows != 0 then + return -1 +endi + + + + + diff --git a/tests/script/general/tag/3.sim b/tests/script/general/tag/3.sim new file mode 100644 index 0000000000..b972bdf975 --- /dev/null +++ b/tests/script/general/tag/3.sim @@ -0,0 +1,523 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_3_db +$tbPrefix = ta_3_tb +$mtPrefix = ta_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/tag/4.sim b/tests/script/general/tag/4.sim new file mode 100644 index 0000000000..d75f5478c1 --- /dev/null +++ b/tests/script/general/tag/4.sim @@ -0,0 +1,713 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_4_db +$tbPrefix = ta_4_tb +$mtPrefix = ta_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/tag/5.sim b/tests/script/general/tag/5.sim new file mode 100644 index 0000000000..bf8cb9358a --- /dev/null +++ b/tests/script/general/tag/5.sim @@ -0,0 +1,836 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_5_db +$tbPrefix = ta_5_tb +$mtPrefix = ta_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/tag/6.sim b/tests/script/general/tag/6.sim new file mode 100644 index 0000000000..3705ffc110 --- /dev/null +++ b/tests/script/general/tag/6.sim @@ -0,0 +1,991 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect +sql reset query cache + +print ======================== dnode1 start + +$dbPrefix = ta_6_db +$tbPrefix = ta_6_tb +$mtPrefix = ta_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tgcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/tag/add.sim b/tests/script/general/tag/add.sim new file mode 100644 index 0000000000..b36bc0c6c3 --- /dev/null +++ b/tests/script/general/tag/add.sim @@ -0,0 +1,854 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ad_db +$tbPrefix = ta_ad_tb +$mtPrefix = ta_ad_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data33 != 2.000000 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print select * from $mt where tgcol5 = 5 +print $data01 $data02 $data03 $data04 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=5 +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4=3 +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=7 +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table $mt add tag tgcol3 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 bigint + +return +sql alter table $mt add tag tgcol7 bigint -x step141 + return -1 +step141: +sql reset query cache +sql alter table $mt drop tag tgcol6 +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 bigint -x step142 + return -1 +step142: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/bigint.sim b/tests/script/general/tag/bigint.sim new file mode 100644 index 0000000000..5519f6759e --- /dev/null +++ b/tests/script/general/tag/bigint.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bi_db +$tbPrefix = ta_bi_tb +$mtPrefix = ta_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/binary.sim b/tests/script/general/tag/binary.sim new file mode 100644 index 0000000000..f5e779bfee --- /dev/null +++ b/tests/script/general/tag/binary.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_by_db +$tbPrefix = ta_by_tb +$mtPrefix = ta_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/binary_binary.sim b/tests/script/general/tag/binary_binary.sim new file mode 100644 index 0000000000..f2622bd034 --- /dev/null +++ b/tests/script/general/tag/binary_binary.sim @@ -0,0 +1,309 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bib_db +$tbPrefix = ta_bib_tb +$mtPrefix = ta_bib_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/bool.sim b/tests/script/general/tag/bool.sim new file mode 100644 index 0000000000..fb69a0ac67 --- /dev/null +++ b/tests/script/general/tag/bool.sim @@ -0,0 +1,239 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bo_db +$tbPrefix = ta_bo_tb +$mtPrefix = ta_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/bool_binary.sim b/tests/script/general/tag/bool_binary.sim new file mode 100644 index 0000000000..55542d7de7 --- /dev/null +++ b/tests/script/general/tag/bool_binary.sim @@ -0,0 +1,309 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_bob_db +$tbPrefix = ta_bob_tb +$mtPrefix = ta_bob_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/bool_int.sim b/tests/script/general/tag/bool_int.sim new file mode 100644 index 0000000000..261bbfb3d8 --- /dev/null +++ b/tests/script/general/tag/bool_int.sim @@ -0,0 +1,325 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_boi_db +$tbPrefix = ta_boi_tb +$mtPrefix = ta_boi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/change.sim b/tests/script/general/tag/change.sim new file mode 100644 index 0000000000..b77e5765d2 --- /dev/null +++ b/tests/script/general/tag/change.sim @@ -0,0 +1,514 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ch_db +$tbPrefix = ta_ch_tb +$mtPrefix = ta_ch_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tagcx tgcol3 -x step21 + return -1 +step21: +sql alter table $mt change tag tgcol1 tgcol2 -x step22 + return -1 +step22: +sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 + return -1 +step20: + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 +sql alter table $mt change tag tgcol4 tgcol3 -x step23 + return -1 +step23: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql reset query cache +sql alter table $mt change tag tgcol4 tgcol3 +sql alter table $mt change tag tgcol1 tgcol7 +sql alter table $mt change tag tgcol2 tgcol8 +sql reset query cache +sql alter table $mt change tag tgcol3 tgcol9 +sql alter table $mt change tag tgcol5 tgcol10 +sql alter table $mt change tag tgcol6 tgcol11 + +sleep 5000 +sql reset query cache + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step24 + return -1 +step24: +sql select * from $mt where tgcol2 = 1 -x step25 + return -1 +step25: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step31 + return -1 +step31: +sql select * from $mt where tgcol2 = 1 -x step32 + return -1 +step32: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step41 + return -1 +step41: +sql select * from $mt where tgcol2 = 1 -x step42 + return -1 +step42: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol2 = 1 -x step52 + return -1 +step52: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = '2' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step61 + return -1 +step61: +sql select * from $mt where tgcol2 = 1 -x step62 + return -1 +step62: +sql select * from $mt where tgcol3 = 1 -x step63 + return -1 +step63: +sql select * from $mt where tgcol4 = 1 -x step64 + return -1 +step64: +sql select * from $mt where tgcol5 = 1 -x step65 + return -1 +step65: +sql select * from $mt where tgcol6 = 1 -x step66 + return -1 +step66: + +sql select * from $mt where tgcol7 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol8 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol9 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol10 = 5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol11 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/column.sim b/tests/script/general/tag/column.sim new file mode 100644 index 0000000000..a7f1b1c8c2 --- /dev/null +++ b/tests/script/general/tag/column.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_co_db +$tbPrefix = ta_co_tb +$mtPrefix = ta_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db + +$i = 0 +sql create table $mt (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + +print =============== step2 + +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 0, '0' ) + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '2', '2' ) + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '3', 3 ) + +sql show tables +if $rows != 4 then + return -1 +endi + +print =============== step3 + +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 0, '0') + +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '2', '2') + +$i = 3 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '3', 3) + +print =============== step4 +sql select * from $mt where tgcol2 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql select * from $mt +if $rows != 4 then + return -1 +endi + +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/commit.sim b/tests/script/general/tag/commit.sim new file mode 100644 index 0000000000..84bb72271b --- /dev/null +++ b/tests/script/general/tag/commit.sim @@ -0,0 +1,1183 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data33 != 2.000000 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=5 +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4=3 +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=7 +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/create.sim b/tests/script/general/tag/create.sim new file mode 100644 index 0000000000..9742b1c8da --- /dev/null +++ b/tests/script/general/tag/create.sim @@ -0,0 +1,600 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_cr_db +$tbPrefix = ta_cr_tb +$mtPrefix = ta_cr_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) +sql create table $tb using $mt tags( '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 0 then + return -1 +endi + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi +print =============== step15 +$i = 15 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step16 +$i = 16 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step17 +$i = 17 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = true +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step18 +$i = 18 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step19 +$i = 19 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step20 +$i = 20 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step21 +$i = 21 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step22 +$i = 22 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step23 +$i = 23 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step24 +$i = 24 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol4 = 4 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol5 = 5 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step25 +$i = 25 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step26 +$i = 26 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4', '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step27 +$i = 27 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27 + return -1 +step27: + +print =============== step28 +$i = 28 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step29 +$i = 29 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step30 +$i = 30 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 + return -1 +step30: + +print =============== step31 +$i = 31 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5)) +sql_error create table $tb using $mt tags('1234567') +sql create table $tb using $mt tags('12345') +sql insert into $tb values(now, 1) +sql select * from $mt +print sql select * from $mt +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data02 != 12345 then + return -1 +endi diff --git a/tests/script/general/tag/delete.sim b/tests/script/general/tag/delete.sim new file mode 100644 index 0000000000..2a0e3ea58c --- /dev/null +++ b/tests/script/general/tag/delete.sim @@ -0,0 +1,826 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_de_db +$tbPrefix = ta_de_tb +$mtPrefix = ta_de_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 < 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != 1 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step40 + return -1 +step40: +sql alter table $mt drop tag tgcol2 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step50 + return -1 +step50: +sql alter table $mt drop tag tgcol2 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql describe $tb +if $data21 != SMALLINT then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data33 != 2 then + return -1 +endi +if $data43 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, '2', '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 +sql alter table $mt drop tag tgcol6 + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 + +sleep 5000 + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: +sql select * from $mt where tgcol4 = 1 -x step103 + return -1 +step103: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4=4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol5 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.000000000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step120 + return -1 +step120: +sql select * from $mt where tgcol3 = 1 -x step121 + return -1 +step121: +sql select * from $mt where tgcol5 = 1 -x step122 + return -1 +step122: +sql select * from $mt where tgcol6 = 1 -x step123 + return -1 +step123: + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql reset query cache +sql select * from $mt where tgcol2 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step130 + return -1 +step130: +sql select * from $mt where tgcol4 = 1 -x step131 + return -1 +step131: +sql select * from $mt where tgcol6 = 1 -x step133 + return -1 +step133: + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table xxmt drop tag tag1 -x step141 + return -1 +step141: +sql alter table $tb drop tag tag1 -x step142 + return -1 +step142: +sql alter table $mt drop tag tag1 -x step143 + return -1 +step143: + +sql alter table $mt drop tag tagcol1 -x step144 + return -1 +step144: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol1 -x step145 + return -1 +step145: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/double.sim b/tests/script/general/tag/double.sim new file mode 100644 index 0000000000..8c5831b74c --- /dev/null +++ b/tests/script/general/tag/double.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_do_db +$tbPrefix = ta_do_tb +$mtPrefix = ta_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/filter.sim b/tests/script/general/tag/filter.sim new file mode 100644 index 0000000000..6d8f9ff893 --- /dev/null +++ b/tests/script/general/tag/filter.sim @@ -0,0 +1,148 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_fi_db +$tbPrefix = ta_fi_tb +$mtPrefix = ta_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 + return -1 +step2: + +print =============== step3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 + return -1 +step3: + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + return -1 +step6: + +print =============== step7 +sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + return -1 +step7: + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 + return -1 +step9: + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as c from $mt group by tbcol + +print =============== step12 +sql select count(tbcol) as c from $mt group by noexist -x step12 + return -1 +step12: + +print =============== step13 +sql select count(tbcol) as c from $mt group by tgcol +print $data00 +if $data00 != 100 then + return -1 +endi + +print =============== step14 +sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 + return -1 +step15: + +print =============== step16 +sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/general/tag/float.sim b/tests/script/general/tag/float.sim new file mode 100644 index 0000000000..49fcf8029b --- /dev/null +++ b/tests/script/general/tag/float.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_fl_db +$tbPrefix = ta_fl_tb +$mtPrefix = ta_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/int.sim b/tests/script/general/tag/int.sim new file mode 100644 index 0000000000..d663dd6eb0 --- /dev/null +++ b/tests/script/general/tag/int.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_in_db +$tbPrefix = ta_in_tb +$mtPrefix = ta_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/int_binary.sim b/tests/script/general/tag/int_binary.sim new file mode 100644 index 0000000000..29220eb92f --- /dev/null +++ b/tests/script/general/tag/int_binary.sim @@ -0,0 +1,309 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_inb_db +$tbPrefix = ta_inb_tb +$mtPrefix = ta_inb_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/int_float.sim b/tests/script/general/tag/int_float.sim new file mode 100644 index 0000000000..4cb85b7e3d --- /dev/null +++ b/tests/script/general/tag/int_float.sim @@ -0,0 +1,325 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_inf_db +$tbPrefix = ta_inf_tb +$mtPrefix = ta_inf_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 > 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 < 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/set.sim b/tests/script/general/tag/set.sim new file mode 100644 index 0000000000..0c6ddd17d0 --- /dev/null +++ b/tests/script/general/tag/set.sim @@ -0,0 +1,458 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_se_db +$tbPrefix = ta_se_tb +$mtPrefix = ta_se_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tagcx 1 -x step21 + return -1 +step21: +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = false +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql describe $tb +print $data21 $data23 $data32 $data33 +if $data21 != BOOL then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data23 != false then + return -1 +endi +if $data33 != 4 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 2 +if $rows != 0 then + return -1 +endi + + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tgcol1=3 +sql alter table $tb set tag tgcol2='4' + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $tb set tag tgcol1='7' +sql alter table $tb set tag tgcol2=8 +sql alter table $tb set tag tgcol4='9' +sql alter table $tb set tag tgcol5=10 +sql alter table $tb set tag tgcol6='11' + +sql reset query cache + +sql select * from $mt where tgcol1 = '7' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 8 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol4 = '9' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol5 = 10 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol6 = '11' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/smallint.sim b/tests/script/general/tag/smallint.sim new file mode 100644 index 0000000000..f38f6e2340 --- /dev/null +++ b/tests/script/general/tag/smallint.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_sm_db +$tbPrefix = ta_sm_tb +$mtPrefix = ta_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/tag/testSuite.sim b/tests/script/general/tag/testSuite.sim new file mode 100644 index 0000000000..ffe61c54fd --- /dev/null +++ b/tests/script/general/tag/testSuite.sim @@ -0,0 +1,25 @@ +run lite/tag/filter.sim +run lite/tag/column.sim +run lite/tag/bool.sim +run lite/tag/smallint.sim +run lite/tag/tinyint.sim +run lite/tag/int.sim +run lite/tag/bigint.sim +run lite/tag/float.sim +run lite/tag/double.sim +run lite/tag/binary.sim +run lite/tag/bool_int.sim +run lite/tag/bool_binary.sim +run lite/tag/int_float.sim +run lite/tag/int_binary.sim +run lite/tag/binary_binary.sim +run lite/tag/3.sim +run lite/tag/4.sim +run lite/tag/5.sim +run lite/tag/6.sim +run lite/tag/create.sim +run lite/tag/delete.sim +run lite/tag/change.sim +run lite/tag/set.sim +run lite/tag/add.sim +run lite/tag/commit.sim \ No newline at end of file diff --git a/tests/script/general/tag/tinyint.sim b/tests/script/general/tag/tinyint.sim new file mode 100644 index 0000000000..f88cf0f61d --- /dev/null +++ b/tests/script/general/tag/tinyint.sim @@ -0,0 +1,242 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ti_db +$tbPrefix = ta_ti_tb +$mtPrefix = ta_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/metrics_field.sim b/tests/script/general/vector/metrics_field.sim new file mode 100644 index 0000000000..187ad51ca2 --- /dev/null +++ b/tests/script/general/vector/metrics_field.sim @@ -0,0 +1,621 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mf_db +$tbPrefix = m_mf_tb +$mtPrefix = m_mf_mt + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/metrics_mix.sim b/tests/script/general/vector/metrics_mix.sim new file mode 100644 index 0000000000..3baf3732f1 --- /dev/null +++ b/tests/script/general/vector/metrics_mix.sim @@ -0,0 +1,621 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mx_db +$tbPrefix = m_mx_tb +$mtPrefix = m_mx_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - ffrom $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step020 + return -1 +step020: + +sql select a -f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/metrics_query.sim b/tests/script/general/vector/metrics_query.sim new file mode 100644 index 0000000000..3690c9f29c --- /dev/null +++ b/tests/script/general/vector/metrics_query.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mq_db +$tbPrefix = m_mq_tb +$mtPrefix = m_mq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt -x step21 + return -1 +step21: + +sql select h - f from $mt -x step22 + return -1 +step22: + +sql select ts - f from $mt -x step23 + return -1 +step23: + +sql select a - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/metrics_tag.sim b/tests/script/general/vector/metrics_tag.sim new file mode 100644 index 0000000000..f4a4eea53f --- /dev/null +++ b/tests/script/general/vector/metrics_tag.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mtg_db +$tbPrefix = m_mtg_tb +$mtPrefix = m_mtg_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/metrics_time.sim b/tests/script/general/vector/metrics_time.sim new file mode 100644 index 0000000000..b2fa6e98b0 --- /dev/null +++ b/tests/script/general/vector/metrics_time.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mt_db +$tbPrefix = m_mt_tb +$mtPrefix = m_mt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/multi.sim b/tests/script/general/vector/multi.sim new file mode 100644 index 0000000000..c9c7a95c71 --- /dev/null +++ b/tests/script/general/vector/multi.sim @@ -0,0 +1,215 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_mu_db +$tbPrefix = m_mu_tb +$mtPrefix = m_mu_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f binary(10), g bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + e from $tb where ts < now + 4m order by ts desc + +sql select a + a from $tb where ts > now + 4m order by ts desc + +sql select a + c from $tb where ts < now + 4m order by ts asc + +sql select a + f from $tb where ts > now + 4m order by ts asc -x step24 + return -1 +step24: + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - e from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select a - b from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * b + e from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select a * b + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a * b -d from $tb where ts > now + 4m +print ===> $data20 +if $data20 != 42.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / 2 + e from $tb +print ===> $data00 +if $data00 != 10.500000000 then + return -1 +endi + +sql select a / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 1.000000000 then + return -1 +endi + +sql select a / 2 * e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +sql select a + ts from $tb -x step61 + return -1 +step61: + +sql select a + f from $tb -x step62 + return -1 +step62: + +sql select a + g from $tb -x step63 + return -1 +step63: + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb where a = 2 +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select * from $tb where b < 2 +print ===> $rows +if $rows != 1 then + return -1 +endi + +sql select * from $tb where b > 2 +print ===> $rows +if $rows != 17 then + return -1 +endi + +sql select a + c from $tb where b = 2 and ts < now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select a + d from $tb where c = 10 and ts > now + 4m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where d = 2 and ts < now + 4m order by ts desc + +sql select a + a from $tb where e = 2 and ts > now + 4m order by ts desc + +sql select a + c from $tb where f = 2 and ts < now + 4m order by ts asc + +sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step74 + return -1 +step74: + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/single.sim b/tests/script/general/vector/single.sim new file mode 100644 index 0000000000..e87de13745 --- /dev/null +++ b/tests/script/general/vector/single.sim @@ -0,0 +1,301 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_si_db +$tbPrefix = m_si_tb +$mtPrefix = m_si_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol + 1 from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 6.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts asc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts asc + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol - 1 from $tb +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 0.500000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select tbcol / 0 from $tb where ts > now + 4m +print ===> $data00 +#if $data00 != 0.000000000 then +# return -1 +#endi + +print =============== step6 +$i = 11 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bool) +sql insert into $tb values(now, 0) +sql select tbcol + 2 from $tb -x step6 + return -1 +step6: + +print =============== step7 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol tinyint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step8 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol smallint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step9 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bigint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step10 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol float) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step11 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol double) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step12 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol binary(100)) +sql insert into $tb values(now, '0'); +sql select tbcol + 2 from $tb -x step12 + return -1 +step12: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/table_field.sim b/tests/script/general/vector/table_field.sim new file mode 100644 index 0000000000..0308ff78c3 --- /dev/null +++ b/tests/script/general/vector/table_field.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_tf_db +$tbPrefix = m_tf_tb +$mtPrefix = m_tf_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/table_mix.sim b/tests/script/general/vector/table_mix.sim new file mode 100644 index 0000000000..0c88406022 --- /dev/null +++ b/tests/script/general/vector/table_mix.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_tm_db +$tbPrefix = m_tm_tb +$mtPrefix = m_tm_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/table_query.sim b/tests/script/general/vector/table_query.sim new file mode 100644 index 0000000000..5a94f30585 --- /dev/null +++ b/tests/script/general/vector/table_query.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_tq_db +$tbPrefix = m_tq_tb +$mtPrefix = m_tq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb -x step21 + return -1 +step21: + +sql select h - f from $tb -x step22 + return -1 +step22: + +sql select ts - f from $tb -x step23 + return -1 +step23: + +sql select a - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $tb +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/table_time.sim b/tests/script/general/vector/table_time.sim new file mode 100644 index 0000000000..6a661ba969 --- /dev/null +++ b/tests/script/general/vector/table_time.sim @@ -0,0 +1,617 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +sql connect + +$dbPrefix = m_tt_db +$tbPrefix = m_tt_tb +$mtPrefix = m_tt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/vector/testSuite.sim b/tests/script/general/vector/testSuite.sim new file mode 100644 index 0000000000..65bfffa1ad --- /dev/null +++ b/tests/script/general/vector/testSuite.sim @@ -0,0 +1,12 @@ +run lite/vector/single.sim +run lite/vector/multi.sim +run lite/vector/table_query.sim +run lite/vector/table_time.sim +run lite/vector/table_field.sim +run lite/vector/table_mix.sim +run lite/vector/metrics_query.sim +run lite/vector/metrics_tag.sim +run lite/vector/metrics_time.sim +run lite/vector/metrics_field.sim +run lite/vector/metrics_mix.sim + diff --git a/tests/script/unique/account/account_create.sim b/tests/script/unique/account/account_create.sim new file mode 100644 index 0000000000..0963739ec9 --- /dev/null +++ b/tests/script/unique/account/account_create.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============================ dnode1 start + +$i = 0 +$dbPrefix = acdb +$tbPrefix = actb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$accountPrefix = acac + +print =============== step1-4 +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 3 then + return -1 +endi + +$i = 0 +$acc = $accountPrefix . $i +sql_error create account $acc PASS pass123 +sql create account $acc PASS 'pass123' +#sql create account $acc PASS 'pass123' -x step1 +# return -1 +#step1: +sql create user $acc PASS 'pass123' -x step2 + return -1 +step2: + +sql show accounts +if $rows != 2 then + return -1 +endi + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5-6 +sql drop account $acc +sql drop account $acc -x step5 + return -1 +step5: +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step7 +sql create account $acc PASS 'pass123' +#sql create account $acc PASS 'pass123' -x step7 +# return -1 +#step7: + +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account $acc +sql show accounts +if $rows != 1 then + return -1 +endi + + diff --git a/tests/script/unique/account/account_delete.sim b/tests/script/unique/account/account_delete.sim new file mode 100644 index 0000000000..2a140961bb --- /dev/null +++ b/tests/script/unique/account/account_delete.sim @@ -0,0 +1,91 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============= step1 +sql create account oroot pass 'taosdata' +sql close +sql connect oroot +sleep 2000 + +print ============= step2 +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' + +sql create database d1 +sql create database d2 +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d2.t2 values(now+1s, 2) + +sql show databases +if $rows != 2 then + return -1 +endi +sql show users +if $rows != 4 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +print ============= step3 +sql close +sql connect +sleep 2000 + +sql show databases +if $rows != 0 then + return -1 +endi +sql show dnodes +if $data02 != 2 then + return -1 +endi +sql drop account oroot + +print ============= step4 +sleep 2000 +sql show dnodes +if $data02 != 0 then + return -1 +endi + +print ============= step5 +sql create account oroot pass 'taosdata' + +sql close +sql connect oroot +sleep 2000 + +sql show databases +if $rows != 0 then + return -1 +endi +sql show users +if $rows != 2 then + return -1 +endi + +sql close +sql connect +sleep 2000 +sql drop account oroot +sql show accounts +if $rows != 1 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/account/account_len.sim b/tests/script/unique/account/account_len.sim new file mode 100644 index 0000000000..759e469aa8 --- /dev/null +++ b/tests/script/unique/account/account_len.sim @@ -0,0 +1,92 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = aldb +$tbPrefix = altb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop account ac -x step0 + return -1 +step0: + +sql create account PASS 123 -x step1 + return -1 +step1: + +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql drop account a -x step2 +step2: +sql create account a PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account a +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop account abc01234567890123456789 -x step3 +step3: +sql create account abc01234567890123456789 PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account abc01234567890123456789 +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step4 +sql create account abcd01234567890123456789012345689012345 PASS '123' -x step4 + return -1 +step4: +sql show accounts +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql drop account 123 -x step5 +step5: +sql create account 123 pass '123' -x step51 + return -1 +step51: + +sql create account a123 PASS '123' +sql show accounts +if $rows != 2 then + return -1 +endi + +sql drop account a123 +sql show accounts +if $rows != 1 then + return -1 +endi + +sql show users +if $rows != 3 then + return -1 +endi diff --git a/tests/script/unique/account/authority.sim b/tests/script/unique/account/authority.sim new file mode 100644 index 0000000000..c37b4e39b6 --- /dev/null +++ b/tests/script/unique/account/authority.sim @@ -0,0 +1,346 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============= step1 + +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' +sql create user manage pass 'taosdata' + +sql create user a PASS 'ade' privilege -x step11 + return -1 +step11: + +sql create user a PASS 'ade' privilege a -x step12 + return -1 +step12: + +sql create user a PASS 'ade' privilege read -x step13 + return -1 +step13: + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi + +sql alter user read privilege read +sql alter user write privilege write +sql_error alter user manage privilege super + +print ============= step2 +sql close +sql connect write +sleep 2000 + +sql create database d1 +sql create database d2 +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d2.t2 values(now+1s, 2) + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account t1 pass 'taosdata' -x step21 + return -1 +step21: + +sql create user t1 pass 'taosdata' -x step22 + return -1 +step22: + +sql alter user read pass 'taosdata' -x step23 + return -1 +step23: + +sql create dnode 192.168.0.2 -x step24 + return -1 +step24: + +sql drop dnode 192.168.0.2 -x step25 + return -1 +step25: + +sql create mnode 192.168.0.2 -x step26 + return -1 +step26: + +sql drop mnode 192.168.0.2 -x step27 + return -1 +step27: + +sql drop account root -x step28 + return -1 +step28: + +sql alter user write pass 'taosdata' + +print ============= step3 +sql close +sql connect read +sleep 2000 + +sql create database d3 -x step31 + return -1 +step31: + +sql create table d1.t3 (ts timestamp, i int) -x step32 + return -1 +step32: + +#sql insert into d1.t1 values(now, 2) -x step33 +# return -1 +#step33: + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step34 + return -1 +step34: + +sql sql create user t1 pass 'taosdata' -x step35 + return -1 +step35: + +print ============= step4 +sql close +sql connect manage +sleep 2000 + +sql create database d3 +sql create database d4 +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 4 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account other pass 'taosdata' -x step41 + return -1 +step41: + +sql close +sql connect +sleep 2000 +sql create account other pass 'taosdata' + +print ============= step5 +sql close +sql connect other +sleep 2000 +sql create user read pass 'taosdata' -x step51 + return -1 +step51: +sql create other write pass 'taosdata' -x step52 + return -1 +step52: + +sql create user oread pass 'taosdata' +sql create user owrite pass 'taosdata' +sql create user omanage pass 'taosdata' + +sql show users +print show users $rows +if $rows != 5 then + return -1 +endi + +sql alter user oread privilege read +sql alter user owrite privilege write +sql alter user oroot privilege super -x step53 + return -1 +step53: +sql alter user read privilege read -x step54 + return -1 +step54: + +print ============= step6 +sql close +sql connect owrite +sleep 2000 + +sql create database d1 +sql create database d3 +sql create table d1.t1 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql insert into d1.t1 values(now, 11) +sql insert into d3.t3 values(now, 11) +sql insert into d3.t3 values(now+1s, 12) + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step6 + return -1 +step6: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step61 + return -1 +step61: + +sql sql create user t1 pass 'taosdata' -x step62 + return -1 +step62: + +print ============= step7 +sql close +sql connect oread +sleep 2000 + +sql create database d7 -x step71 + return -1 +step71: + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step72 + return -1 +step72: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step73 + return -1 +step73: + +sql sql create user t1 pass 'taosdata' -x step74 + return -1 +step74: + +print ============= step8 +sql close +sql connect omanage +sleep 2000 + +sql create account t1 pass 'taosdata' -x step81 + return -1 +step81: + +sql create database d4 +sql create table d4.t4 (ts timestamp, i int) + +sql show databases +if $rows != 3 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step82 + return -1 +step82: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +print ============= step9 +sql close +sql connect +sleep 2000 +sql show databases +if $rows != 4 then + return -1 +endi + +sql drop account other +sql drop user read +sql drop user manage +sql drop user write + +sql close +sql connect +sleep 2000 +sql drop database d1 +sql drop database d2 +sql drop database d3 +sql drop database d4 diff --git a/tests/script/unique/account/monitor.sim b/tests/script/unique/account/monitor.sim new file mode 100644 index 0000000000..ea5155afbc --- /dev/null +++ b/tests/script/unique/account/monitor.sim @@ -0,0 +1,36 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c monitor -v 0 + +print ========== step1 +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ========== step2 +sql drop database log -x step21 + return -1 +step21: +sql drop table log.cpu -x step22 + return -1 +step22: +sql drop user log -x step23 + return -1 +step23: + +print ========== step3 + +sleep 3000 +sql select * from log.dn +if $rows == 0 then + return -1 +endi + + + + diff --git a/tests/script/unique/account/pass_alter.sim b/tests/script/unique/account/pass_alter.sim new file mode 100644 index 0000000000..3314eda56f --- /dev/null +++ b/tests/script/unique/account/pass_alter.sim @@ -0,0 +1,115 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============= step1 +sql create user read pass 'taosdata1' +sql create user write pass 'taosdata1' + +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata' + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step2 +sql close +sql connect read +sleep 2000 +sql alter user read pass 'taosdata' +sql alter user write pass 'taosdata1' -x step2 + return -1 +step2: + + +print ============= step3 +sql close +sql connect write +sleep 2000 +sql alter user write pass 'taosdata' +sql alter user read pass 'taosdata' -x step3 + return -1 +step3: + +print ============= step4 +sql close +sql connect +sleep 2000 +sql create account oroot pass 'taosdata' +sql show accounts +if $rows != 2 then + return -1 +endi +sql show users +if $rows != 5 then + return -1 +endi + +print ============= step5 +sql close +sql connect oroot +sleep 2000 + +sql create user oread pass 'taosdata1' +sql create user owrite pass 'taosdata1' +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata' + +sql create user read pass 'taosdata1' -x step51 + return -1 +step51: +sql alter user read pass 'taosdata1' -x step52 + return -1 +step52: + +sql show accounts -x step53 + return -1 +step53: +sql show users +print show users $rows +if $rows != 4 then + return -1 +endi + +print ============= step6 +sql close +sql connect oread +sleep 2000 +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata1' -x step6 + return -1 +step6: + + +print ============= step7 +sql close +sql connect owrite +sleep 2000 +sql alter user owrite pass 'taosdata' +sql alter user oread pass 'taosdata' -x step7 + return -1 +step7: + +print ============= step8 +sql close +sql connect +sleep 2000 +sql alter user oread pass 'taosdata' +sql alter user owrite pass 'taosdata' +sql alter user oroot pass 'taosdata' + +sql drop account oroot +sql drop user read +sql drop user write diff --git a/tests/script/unique/account/pass_len.sim b/tests/script/unique/account/pass_len.sim new file mode 100644 index 0000000000..45d27d40c3 --- /dev/null +++ b/tests/script/unique/account/pass_len.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = apdb +$tbPrefix = aptb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +$userPrefix = apusr + +print =============== step1 +$i = 0 +$user = $userPrefix . $i + +sql drop user $user -x step11 + return -1 +step11: + +sql create user $user PASS -x step12 + return -1 +step12: + +sql create user $user PASS 'taosdata' + +sql show users +if $rows != 4 then + return -1 +endi + +print =============== step2 +$i = 1 +$user = $userPrefix . $i +sql drop user $user -x step2 +step2: +sql create user $user PASS '1' +sql show users +if $rows != 5 then + return -1 +endi + +print =============== step3 +$i = 2 +$user = $userPrefix . $i +sql drop user $user -x step3 +step3: + +sql create user $user PASS 'abc0123456789' +sql show users +if $rows != 6 then + return -1 +endi + +print =============== step4 +$i = 3 +$user = $userPrefix . $i +sql create user $user PASS 'abcd012345678901234567891234567890' -x step4 + return -1 +step4: +sql show users +if $rows != 6 then + return -1 +endi + +$i = 0 +while $i < 3 + $user = $userPrefix . $i + sql drop user $user + $i = $i + 1 +endw + +sql show users +if $rows != 3 then + return -1 +endi + + diff --git a/tests/script/unique/account/testSuite.sim b/tests/script/unique/account/testSuite.sim new file mode 100644 index 0000000000..542c5c23d1 --- /dev/null +++ b/tests/script/unique/account/testSuite.sim @@ -0,0 +1,9 @@ +run cluster/account/account_create.sim +run cluster/account/account_len.sim +run cluster/account/pass_alter.sim +run cluster/account/pass_len.sim +run cluster/account/authority.sim +run cluster/account/account_delete.sim +run cluster/account/user_create.sim +run cluster/account/user_len.sim +run cluster/account/monitor.sim diff --git a/tests/script/unique/account/user_create.sim b/tests/script/unique/account/user_create.sim new file mode 100644 index 0000000000..09a86fb2e0 --- /dev/null +++ b/tests/script/unique/account/user_create.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print =============== step1 +sql show users +if $rows != 3 then + return -1 +endi + +sql create user read PASS 'pass123' +sql create user read PASS 'pass123' -x step1 + return -1 +step1: + +sql show users +if $rows != 4 then + return -1 +endi + +sql alter user read PASS 'taosdata' + +print =============== step2 +sql close +sql connect read +sleep 2000 + +sql alter user read PASS 'taosdata' + +print =============== step3 +sql drop user read -x step31 + return -1 +step31: +sql drop user sys -x step32 + return -1 +step32: +sql drop user stream -x step33 + return -1 +step33: + +print =============== step4 +sql close +sql connect +sleep 2000 + +sql alter user read privilege read +sql show users +if $data1_read != read then + return -1 +endi + +sql_error alter user read privilege super +sql show users +if $data1_read != read then + return -1 +endi + +sql alter user read privilege write +sql show users +if $data1_read != write then + return -1 +endi + +sql alter user read privilege 1 -x step43 + return -1 +step43: + +sql drop user sys -x step41 + return -1 +step41: + +sql drop user stream -x step42 + return -1 +step42: + +sql drop user read + + + + + diff --git a/tests/script/unique/account/user_len.sim b/tests/script/unique/account/user_len.sim new file mode 100644 index 0000000000..0da5209a2c --- /dev/null +++ b/tests/script/unique/account/user_len.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_us_db +$tbPrefix = lm_us_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop user ac -x step0 + return -1 +step0: + +sql create user PASS '123' -x step1 + return -1 +step1: + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step2 +sql drop user a -x step2 +step2: +sql create user a PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step3 +sql drop user abc01234567890123456789 -x step3 +step3: + +sql create user abc01234567890123456789 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user abc01234567890123456789 +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step4 +sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 + return -1 +step4: +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5 +sql drop user 123 -x step5 +step5: +sql create user 123 PASS '123' -x step61 + return -1 +step61: + +sql create user a123 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a123 +sql show users +if $rows != 3 then + return -1 +endi + +sql show accounts +if $rows != 1 then + return -1 +endi diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim new file mode 100644 index 0000000000..10d13b4460 --- /dev/null +++ b/tests/script/unique/big/balance.sim @@ -0,0 +1,312 @@ +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c tables -v 1000 + +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c tables -v 1000 + +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c tables -v 1000 + +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c tables -v 1000 + +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c tables -v 1000 + +print =============== prepare data +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +$i = 0 +$tbNum = 4000 +$rowNum = 1 +$totalNum = 4000 * $rowNum + +sql create database db +sql use db +sql create table mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +$tbPrefix = t +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using mt tags( $i ) + $i = $i + 1 +endw + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1 +endw + +print ========== step0 +sql show db.tables +if $rows != 4000 then + return -1 +endi + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step1 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show1: + $x = $x + 1 + sleep 3000 + if $x == 100 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 2 then + goto show1 +endi +if $data3_192.168.0.2 != 2 then + goto show1 +endi + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + goto show1 +endi + +print ========== step2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 10000 + +print ========== step3 +sql drop dnode 192.168.0.2 + +$x = 0 +show3: + $x = $x + 1 + sleep 3000 + if $x == 100 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 2 then + goto show3 +endi +if $data3_192.168.0.2 != null then + goto show3 +endi +if $data3_192.168.0.3 != 2 then + goto show3 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step4 +sql drop dnode 192.168.0.3 + +$x = 0 +show4: + $x = $x + 1 + sleep 3000 + if $x == 100 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 0 then + goto show4 +endi +if $data3_192.168.0.3 != null then + goto show4 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + return -1 +endi + +print ========== step5 +sql alter database db replica 2 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 3000 + if $x == 100 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 0 then + goto show5 +endi +if $data3_192.168.0.4 != 0 then + goto show5 +endi + +sql select count(*) from t10 +print select count(*) from t10 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t1010 +print select count(*) from t1010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t2010 +print select count(*) from t2010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from t3010 +print select count(*) from t3010 $data00 expect $rowNum +if $data00 != $rowNum then + goto show5 +endi + +sql select count(*) from mt +print select count(*) from mt $data00 expect $rowNum +if $data00 != $totalNum then + goto show5 +endi diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim new file mode 100644 index 0000000000..c3802da1f8 --- /dev/null +++ b/tests/script/unique/big/maxvnodes.sim @@ -0,0 +1,81 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c tables -v 100 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +sql connect +sql create database db +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$x = 0 +while $x < 25600 + $tb = t . $x + sql create table $tb using mt tags( $x ) + sql insert into $tb values (now, $x ) + $x = $x + 1 +endw + +print ========== step2 +sql select * from mt +if $rows != 25600 then + return -1 +endi + +sql select count(*) from mt +if $data00 != 25600 then + return -1 +endi + +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c clog -v 0 +system sh/cfg.sh -n dnode2 -c tables -v 100 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode2 -c maxVnodeConnections -v 100000 +system sh/cfg.sh -n dnode2 -c maxMeterConnections -v 100000 +system sh/cfg.sh -n dnode2 -c maxShellConns -v 100000 +system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 100000 + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 3000 + if $x == 1000 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 126 then + goto show3 +endi +if $data3_192.168.0.2 != 130 then + goto show3 +endi + +print ========== step4 +sql select * from mt +if $rows != 25600 then + return -1 +endi + +sql select count(*) from mt +if $data00 != 25600 then + return -1 +endi diff --git a/tests/script/unique/big/tcp.sim b/tests/script/unique/big/tcp.sim new file mode 100644 index 0000000000..5e1b26aade --- /dev/null +++ b/tests/script/unique/big/tcp.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c tables -v 30000 + +system sh/cfg.sh -n dnode1 -c dDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c mDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c cDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c gcDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c adminDebugFlag -v 131 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/cfg.sh -n dnode1 -c debugFlag -v 131 + +system sh/exec.sh -n dnode1 -s start + +sql connect +print ======================== dnode1 start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$tbNum = 22000 +$rowNum = 10 + +print =============== step1 +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $i = $i + 1 +endw + +print =============== step2 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1000 +endw + +$i = 0 +while $i < 100 + print =============== step3 $i + sql select count(*) from $mt + print ===> $data00 $data01 + if $rows != 1 then + return -1 + endi + if $data00 != 22 then + return -1 + endi + + print =============== step4 $i + sql select * from $mt + print ===> $data00 $data01 + if $rows != 22 then + return -1 + endi + + $i = $i + 1 +endw + +print =============== step3 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values (now, $i , $i ) + + $i = $i + 1000 +endw + +$i = 0 +while $i < 100 + print =============== step5 $i + sql select count(*) from $mt where tgcol < 20200 + print ===> $data00 $data01 + if $rows != 1 then + return -1 + endi + if $data00 != 42 then + return -1 + endi + + print =============== step6 $i + sql select * from $mt where tgcol < 20200 + print ===> $data00 $data01 + if $rows != 42 then + return -1 + endi + + $i = $i + 1 +endw +system sh/stop_dnodes.sh +sleep 10000 diff --git a/tests/script/unique/big/testSuite.sim b/tests/script/unique/big/testSuite.sim new file mode 100644 index 0000000000..178192cff4 --- /dev/null +++ b/tests/script/unique/big/testSuite.sim @@ -0,0 +1,3 @@ +#run cluster/big/balance.sim +#run cluster/big/maxvnodes.sim +run cluster/big/tcp.sim diff --git a/tests/script/unique/cluster/backup/balance4.sim b/tests/script/unique/cluster/backup/balance4.sim new file mode 100644 index 0000000000..fbfd6eb36c --- /dev/null +++ b/tests/script/unique/cluster/backup/balance4.sim @@ -0,0 +1,759 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up +system sh/ip.sh -i 8 -s up + +sleep 1000 + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 +system sh/cfg.sh -n dnode5 -c statusInterval -v 1 +system sh/cfg.sh -n dnode6 -c statusInterval -v 1 +system sh/cfg.sh -n dnode7 -c statusInterval -v 1 +system sh/cfg.sh -n dnode8 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode7 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode8 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode7 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode8 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 +system sh/cfg.sh -n dnode6 -c commitLog -v 0 +system sh/cfg.sh -n dnode7 -c commitLog -v 0 +system sh/cfg.sh -n dnode8 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 4001 + +$x = 0 +created1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database c_b4_d1 replica 4 -x created1 +sql use c_b4_d1 + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b4_t1 (t timestamp, i int) -x create1 +sql insert into c_b4_t1 values(now+1s, 15) +sql insert into c_b4_t1 values(now+2s, 14) +sql insert into c_b4_t1 values(now+2s, 13) +sql insert into c_b4_t1 values(now+3s, 12) +sql insert into c_b4_t1 values(now+4s, 11) + + +sql create database c_b4_d2 replica 4 +sql use c_b4_d2 +$x = 0 +create2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b4_t2 (t timestamp, i int) -x create2 +sql insert into c_b4_t2 values(now+1s, 25) +sql insert into c_b4_t2 values(now+2s, 24) +sql insert into c_b4_t2 values(now+3s, 23) +sql insert into c_b4_t2 values(now+4s, 22) +sql insert into c_b4_t2 values(now+5s, 21) + +sql create database c_b4_d3 replica 4 +sql use c_b4_d3 +$x = 0 +create3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b4_t3 (t timestamp, i int) -x create3 +sql insert into c_b4_t3 values(now+1s, 35) +sql insert into c_b4_t3 values(now+2s, 34) +sql insert into c_b4_t3 values(now+3s, 33) +sql insert into c_b4_t3 values(now+4s, 32) +sql insert into c_b4_t3 values(now+5s, 31) + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 1 then + goto show1 +endi +if $dnode2Vnodes != 1 then + goto show1 +endi +if $dnode3Vnodes != 1 then + goto show1 +endi +if $dnode4Vnodes != 1 then + goto show1 +endi +if $dnode5Vnodes != null then + goto show1 +endi + +print ============================== step2 +print ========= start dnode5 +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode5 -s start +sleep 9000 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + + +if $dnode5Vnodes != 2 then + goto show2 +endi + +print ============================== step3 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 1 then + goto show3 +endi +if $dnode2Vnodes != null then + goto show3 +endi +if $dnode3Vnodes != 1 then + goto show3 +endi +if $dnode4Vnodes != 1 then + goto show3 +endi +if $dnode5Vnodes != 1 then + goto show3 +endi + +system sh/exec.sh -n dnode2 -s stop + +print ============================== step4 +print ========= start dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode2Vnodes != 2 then + goto show4 +endi + +print ============================== step5 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 1 then + goto show5 +endi +if $dnode2Vnodes != 1 then + goto show5 +endi +if $dnode3Vnodes != null then + goto show5 +endi +if $dnode4Vnodes != 1 then + goto show5 +endi +if $dnode5Vnodes != 1 then + goto show5 +endi + +system sh/exec.sh -n dnode3 -s stop + +print ============================== step6 +print ========= start dnode3 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode3Vnodes != 2 then + goto show6 +endi + +print ============================== step7 +print ========= drop dnode4 +sql drop dnode 192.168.0.4 +sleep 9000 + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 1 then + goto show7 +endi +if $dnode2Vnodes != 1 then + goto show7 +endi +if $dnode3Vnodes != 1 then + goto show7 +endi +if $dnode4Vnodes != null then + goto show7 +endi +if $dnode5Vnodes != 1 then + goto show7 +endi + +system sh/exec.sh -n dnode4 -s stop + +print ============================== step8 +print ========= start dnode4 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 9000 + +$x = 0 +show8: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode4Vnodes != 2 then + goto show8 +endi + +print ============================== step9 +print ========= drop dnode5 +sql drop dnode 192.168.0.5 +sleep 9000 + +$x = 0 +show9: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 1 then + goto show9 +endi +if $dnode2Vnodes != 1 then + goto show9 +endi +if $dnode3Vnodes != 1 then + goto show9 +endi +if $dnode4Vnodes != 1 then + goto show9 +endi +if $dnode5Vnodes != null then + goto show9 +endi + +system sh/exec.sh -n dnode5 -s stop + +print ============================== step10 +print ========= start dnode5 +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode5 -s start +sleep 9000 + +$x = 0 +show10: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode5Vnodes != 2 then + goto show10 +endi + +print ============================== step11 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show11: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show11 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != null then + goto show11 +endi +if $dnode2Vnodes != 1 then + goto show11 +endi +if $dnode3Vnodes != 1 then + goto show11 +endi +if $dnode4Vnodes != 1 then + goto show11 +endi +if $dnode5Vnodes != 1 then + goto show11 +endi + +print ============================== step12 +print ========= start dnode1 +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 12000 + +$x = 0 +show12: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show12 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 2 then + goto show12 +endi + +print ============================== step13 +print ========= add db4 + +sql create database c_b4_d4 replica 4 +sql use c_b4_d4 + +$x = 0 +create4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b4_t4 (t timestamp, i int) -x create4 +sql insert into c_b4_t4 values(now+1s, 45) +sql insert into c_b4_t4 values(now+2s, 44) +sql insert into c_b4_t4 values(now+3s, 43) +sql insert into c_b4_t4 values(now+4s, 42) +sql insert into c_b4_t4 values(now+5s, 41) + +sql create database c_b4_d5 replica 4 +sql use c_b4_d5; + +$x = 0 +create5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b4_t5 (t timestamp, i int) -x create5 +sql insert into c_b4_t5 values(now+1s, 55) +sql insert into c_b4_t5 values(now+2s, 54) +sql insert into c_b4_t5 values(now+3s, 53) +sql insert into c_b4_t5 values(now+4s, 52) +sql insert into c_b4_t5 values(now+5s, 51) + +$x = 0 +show13: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show13 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 0 then + goto show13 +endi +if $dnode2Vnodes != 0 then + goto show13 +endi +if $dnode3Vnodes != 0 then + goto show13 +endi +if $dnode4Vnodes != 0 then + goto show13 +endi +if $dnode4Vnodes != 0 then + goto show13 +endi + +print ============================== step14 +print ========= check data + +sql use c_b4_d1 +sql select * from c_b4_t1 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use c_b4_d2 +sql select * from c_b4_t2 +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use c_b4_d3 +sql select * from c_b4_t3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql use c_b4_d4 +sql select * from c_b4_t4 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +sql use c_b4_d5 +sql select * from c_b4_t5 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop +system sh/exec.sh -n dnode7 -s stop +system sh/exec.sh -n dnode8 -s stop + + diff --git a/tests/script/unique/cluster/backup/balance5.sim b/tests/script/unique/cluster/backup/balance5.sim new file mode 100644 index 0000000000..15bc83ab5d --- /dev/null +++ b/tests/script/unique/cluster/backup/balance5.sim @@ -0,0 +1,413 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up +system sh/ip.sh -i 8 -s up + +sleep 1000 + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 +system sh/cfg.sh -n dnode5 -c statusInterval -v 1 +system sh/cfg.sh -n dnode6 -c statusInterval -v 1 +system sh/cfg.sh -n dnode7 -c statusInterval -v 1 +system sh/cfg.sh -n dnode8 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode7 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode8 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode7 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode8 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 +system sh/cfg.sh -n dnode6 -c commitLog -v 0 +system sh/cfg.sh -n dnode7 -c commitLog -v 0 +system sh/cfg.sh -n dnode8 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 4001 + +$x = 0 +created1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database c_b5_d1 replica 5 -x created1 +sql use c_b5_d1 +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b5_t1 (t timestamp, i int) -x create1 +sql insert into c_b5_t1 values(now+1s, 15) +sql insert into c_b5_t1 values(now+2s, 14) +sql insert into c_b5_t1 values(now+2s, 13) +sql insert into c_b5_t1 values(now+3s, 12) +sql insert into c_b5_t1 values(now+4s, 11) + +sql create database c_b5_d2 replica 5 +sql use c_b5_d2 +$x = 0 +create2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b5_t2 (t timestamp, i int) -x create2 +sql insert into c_b5_t2 values(now+1s, 25) +sql insert into c_b5_t2 values(now+2s, 24) +sql insert into c_b5_t2 values(now+3s, 23) +sql insert into c_b5_t2 values(now+4s, 22) +sql insert into c_b5_t2 values(now+5s, 21) + +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 2 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi +if $dnode4Vnodes != 2 then + goto show1 +endi +if $dnode5Vnodes != 2 then + goto show1 +endi + +print ============================== step2 +print ========= start dnode6 + +sql create dnode 192.168.0.6 +system sh/exec.sh -n dnode6 -s start + +sql create database c_b5_d3 replica 5 +sql use c_b5_d3 +$x = 0 +create3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b5_t3 (t timestamp, i int) -x create3 +sql insert into c_b5_t3 values(now+1s, 35) +sql insert into c_b5_t3 values(now+2s, 34) +sql insert into c_b5_t3 values(now+3s, 33) +sql insert into c_b5_t3 values(now+4s, 32) +sql insert into c_b5_t3 values(now+5s, 31) + +sleep 10000 + +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Status = $data4_192.168.0.1 +print 192.168.0.1 $dnode1Status +$dnode2Status = $data4_192.168.0.2 +print 192.168.0.2 $dnode2Status +$dnode3Status = $data4_192.168.0.3 +print 192.168.0.3 $dnode3Status +$dnode4Status = $data4_192.168.0.4 +print 192.168.0.4 $dnode4Status +$dnode5Status = $data4_192.168.0.5 +print 192.168.0.5 $dnode5Status +$dnode6Status = $data4_192.168.0.6 +print 192.168.0.6 $dnode6Status + +if $dnode1Status != online then + goto show2 +endi +if $dnode2Status != online then + goto show2 +endi +if $dnode3Status != online then + goto show2 +endi +if $dnode4Status != online then + goto show2 +endi +if $dnode5Status != online then + goto show2 +endi +if $dnode6Status != online then + goto show2 +endi + +print ============================== step3 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +show3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != null then + goto show3 +endi +if $dnode2Vnodes != 1 then + goto show3 +endi +if $dnode3Vnodes != 1 then + goto show3 +endi +if $dnode4Vnodes != 1 then + goto show3 +endi +if $dnode5Vnodes != 1 then + goto show3 +endi +if $dnode6Vnodes != 1 then + goto show3 +endi + +print ============================== step4 +print ========= add db, start dnode7 + +sql create database c_b5_d4 replica 5 +sql use c_b5_d4 +$x = 0 +create4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b5_t4 (t timestamp, i int) -x create4 + +$x = 0 +insert4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql insert into c_b5_t4 values(now+1s, 45) -x insert4 +sql insert into c_b5_t4 values(now+2s, 44) +sql insert into c_b5_t4 values(now+3s, 43) +sql insert into c_b5_t4 values(now+4s, 42) +sql insert into c_b5_t4 values(now+5s, 41) + +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 + +sql create dnode 192.168.0.7 +system sh/exec.sh -n dnode7 -s start +sql create dnode 192.168.0.8 +system sh/exec.sh -n dnode8 -s start +sleep 9000 + +print ============================== step5 +print ========= check data + +sql use c_b5_d1 +sql select * from c_b5_t1 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use c_b5_d2 +sql select * from c_b5_t2 +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use c_b5_d3 +sql select * from c_b5_t3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql use c_b5_d4 +sql select * from c_b5_t4 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop +system sh/exec.sh -n dnode7 -s stop +system sh/exec.sh -n dnode8 -s stop + + diff --git a/tests/script/unique/cluster/backup/balancex.sim b/tests/script/unique/cluster/backup/balancex.sim new file mode 100644 index 0000000000..8f1cd191d6 --- /dev/null +++ b/tests/script/unique/cluster/backup/balancex.sim @@ -0,0 +1,372 @@ +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up +system sh/ip.sh -i 8 -s up + +sleep 1000 + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 +system sh/cfg.sh -n dnode5 -c statusInterval -v 1 +system sh/cfg.sh -n dnode6 -c statusInterval -v 1 +system sh/cfg.sh -n dnode7 -c statusInterval -v 1 +system sh/cfg.sh -n dnode8 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode7 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode8 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode7 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode8 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode4 -c commitLog -v 1 +system sh/cfg.sh -n dnode5 -c commitLog -v 1 +system sh/cfg.sh -n dnode6 -c commitLog -v 1 +system sh/cfg.sh -n dnode7 -c commitLog -v 1 +system sh/cfg.sh -n dnode8 -c commitLog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 4001 +sql connect + +$x = 0 +created1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database c_bx_d1 replica 4 -x created1 +sql use c_bx_d1 + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_bx_t1 (t timestamp, i int) -x create1 +sql insert into c_bx_t1 values(now+1s, 15) +sql insert into c_bx_t1 values(now+2s, 14) +sql insert into c_bx_t1 values(now+2s, 13) +sql insert into c_bx_t1 values(now+3s, 12) +sql insert into c_bx_t1 values(now+4s, 11) + +sql create database c_bx_d2 replica 4 +sql use c_bx_d2 + +$x = 0 +create2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_bx_t2 (t timestamp, i int) -x create2 +sql insert into c_bx_t2 values(now+1s, 25) +sql insert into c_bx_t2 values(now+2s, 24) +sql insert into c_bx_t2 values(now+3s, 23) +sql insert into c_bx_t2 values(now+4s, 22) +sql insert into c_bx_t2 values(now+5s, 21) + +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi +if $dnode4Vnodes != 2 then + goto show1 +endi + +print ============================== step2 +print ========= start dnode6 + +sql create database c_bx_d3 replica 4 +sql use c_bx_d3 + +$x = 0 +create3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_bx_t3 (t timestamp, i int) -x create3 +sql insert into c_bx_t3 values(now+1s, 35) +sql insert into c_bx_t3 values(now+2s, 34) +sql insert into c_bx_t3 values(now+3s, 33) +sql insert into c_bx_t3 values(now+4s, 32) +sql insert into c_bx_t3 values(now+5s, 31) + +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode5 -s start +sleep 9000 + +show2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode5Vnodes != 2 then + goto show2 +endi + +print ============================== step3 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +show3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != null then + goto show3 +endi +if $dnode2Vnodes != 1 then + goto show3 +endi +if $dnode3Vnodes != 1 then + goto show3 +endi +if $dnode4Vnodes != 1 then + goto show3 +endi +if $dnode5Vnodes != 1 then + goto show3 +endi + +print ============================== step4 +print ========= add db, start dnode7 + +sql create database c_bx_d4 replica 4 +sql use c_bx_d4 + +$x = 0 +create4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_bx_t4 (t timestamp, i int) -x create4 +sql insert into c_bx_t4 values(now+1s, 45) +sql insert into c_bx_t4 values(now+2s, 44) +sql insert into c_bx_t4 values(now+3s, 43) +sql insert into c_bx_t4 values(now+4s, 42) +sql insert into c_bx_t4 values(now+5s, 41) + +print ============================== step5 +print ========= check data + +sql use c_bx_d1 +sql select * from c_bx_d1 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use c_bx_d2 +sql select * from c_bx_d2 +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use c_bx_d3 +sql select * from c_bx_d3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql use c_bx_d4 +sql select * from c_bx_d4 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT + + diff --git a/tests/script/unique/cluster/balance1.sim b/tests/script/unique/cluster/balance1.sim new file mode 100644 index 0000000000..95cfcbd979 --- /dev/null +++ b/tests/script/unique/cluster/balance1.sim @@ -0,0 +1,813 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database c_b1_d1 tables 4 +sql use c_b1_d1 + +sql create table c_b1_t1 (t timestamp, i int) +sql insert into c_b1_t1 values(1520000020015, 15) +sql insert into c_b1_t1 values(1520000021014, 14) +sql insert into c_b1_t1 values(1520000022013, 13) +sql insert into c_b1_t1 values(1520000023012, 12) +sql insert into c_b1_t1 values(1520000024011, 11) + +sql create database c_b1_d2 tables 4 +sql use c_b1_d2 +sql create table c_b1_t2 (t timestamp, i int) +sql insert into c_b1_t2 values(1520000020025, 25) +sql insert into c_b1_t2 values(1520000021024, 24) +sql insert into c_b1_t2 values(1520000022023, 23) +sql insert into c_b1_t2 values(1520000023022, 22) +sql insert into c_b1_t2 values(1520000024021, 21) + +sql show dnodes +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + return -1 +endi +if $dnode2Vnodes != null then + return -1 +endi + +print ============================== step2 +print ========= start dnode2 +sleep 2000 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 5000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 3 then + goto show2 +endi +if $dnode2Vnodes != 3 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step3 +print ========= add db3 +sql create database c_b1_d3 tables 4 +sql use c_b1_d3 +sql create table c_b1_t3 (t timestamp, i int) +sql insert into c_b1_t3 values(1520000020035, 35) +sql insert into c_b1_t3 values(1520000021034, 34) +sql insert into c_b1_t3 values(1520000022033, 33) +sql insert into c_b1_t3 values(1520000023032, 32) +sql insert into c_b1_t3 values(1520000024031, 31) + +print ============================== step4 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 1 then + goto show4 +endi +if $dnode2Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step5 +print ========= add dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show5 +endi +if $dnode2Vnodes != 3 then + goto show5 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step6 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != null then + goto show6 +endi +if $dnode2Vnodes != 1 then + goto show6 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step7 +print ========= add dnode1 +sql create dnode 192.168.0.1 +sleep 3000 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +sleep 23000 +system sh/exec.sh -n dnode1 -s start +sleep 14000 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 3 then + goto show7 +endi +if $dnode2Vnodes != 2 then + goto show7 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step8 +print ========= drop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +print stop dnode2 and sleep 10000 +sleep 20000 +sql drop dnode 192.168.0.2 +print drop dnode2 and sleep 9000 +sleep 19000 + +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 1 then + goto show8 +endi +if $dnode2Vnodes != null then + goto show8 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi + +print ============================== step9 +print ========= add dnode2 +sql create dnode 192.168.0.2 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show9 +endi +if $dnode2Vnodes != 3 then + goto show9 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step10 +print ========= add db4 +sql create database c_b1_d4 tables 4 +sql use c_b1_d4 +sql create table c_b1_t4 (t timestamp, i int) +sql insert into c_b1_t4 values(1520000020045, 45) +sql insert into c_b1_t4 values(1520000021044, 44) +sql insert into c_b1_t4 values(1520000022043, 43) +sql insert into c_b1_t4 values(1520000023042, 42) +sql insert into c_b1_t4 values(1520000024041, 41) + +$x = 0 +show10: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show10 +endi +if $dnode2Vnodes != 2 then + goto show10 +endi + +sql use c_b1_d3 +sql insert into c_b1_t3 values(1520000025036, 36) + +sql use c_b1_d2 +sql insert into c_b1_t2 values(1520000025026, 26) + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role + +if $dnode1Role != master then + return -1 +endi + +print ============================== step11 +print ========= drop dnode2 +sleep 2000 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show11: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show11 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show11 +endi +if $dnode2Vnodes != null then + goto show11 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step12 +print ========= add db5 +sql create database c_b1_d5 tables 4 +sql use c_b1_d5 +sql create table c_b1_t5 (t timestamp, i int) -x error3 +print no enough vnodes, but create success +return -1 +error3: + +print ============================== step13 +print ========= add dnode2 +sql create dnode 192.168.0.2 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sql use c_b1_d5; +sql create table c_b1_t5 (t timestamp, i int) +sql insert into c_b1_t5 values(1520000020055, 55) +sql insert into c_b1_t5 values(1520000021054, 54) +sql insert into c_b1_t5 values(1520000022053, 53) +sql insert into c_b1_t5 values(1520000023052, 52) +sql insert into c_b1_t5 values(1520000024051, 51) + +sql create database c_b1_d6 tables 4 +sql use c_b1_d6 +sql create table c_b1_t6 (t timestamp, i int) +sql insert into c_b1_t6 values(1520000020065, 65) +sql insert into c_b1_t6 values(1520000021064, 64) +sql insert into c_b1_t6 values(1520000022063, 63) +sql insert into c_b1_t6 values(1520000023062, 62) +sql insert into c_b1_t6 values(1520000024061, 61) + +sql show dnodes +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +#if $dnode1Vnodes != 1 then +# return -1 +#endi +#if $dnode2Vnodes != 1 then +# return -1 +#endi + +print ============================== step14 +print ========= add dnode3 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sleep 2000 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 15000 + +$x = 0 +show14: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show14 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show14 +endi +if $dnode2Vnodes != 2 then + goto show14 +endi +if $dnode3Vnodes != 2 then + goto show14 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +print ============================== step15 +print ========= create db7 db8 + +sql create database c_b1_d7 tables 4 +sql use c_b1_d7 +sql create table c_b1_t7 (t timestamp, i int) +sql insert into c_b1_t7 values(1520000020075, 75) +sql insert into c_b1_t7 values(1520000021074, 74) +sql insert into c_b1_t7 values(1520000022073, 73) +sql insert into c_b1_t7 values(1520000023072, 72) +sql insert into c_b1_t7 values(1520000024071, 71) + +sql create database c_b1_d8 tables 4 +sql use c_b1_d8 +sql create table c_b1_t8 (t timestamp, i int) +sql insert into c_b1_t8 values(1520000020085, 85) +sql insert into c_b1_t8 values(1520000021084, 84) +sql insert into c_b1_t8 values(1520000022083, 83) +sql insert into c_b1_t8 values(1520000023082, 82) +sql insert into c_b1_t8 values(1520000024081, 81) + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ========== add dnode4 +sleep 2000 +sql create dnode 192.168.0.4 +print sql create dnode 192.168.0.4 over +system sh/exec.sh -n dnode4 -s start +print sleep 12000 +sleep 12000 +print sleep 12000 over + +$x = 0 +show15: + $x = $x + 1 + sleep 2000 + if $x == 15 then + return -1 + endi +sql show dnodes -x show15 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show15 +endi +if $dnode2Vnodes != 2 then + goto show15 +endi +if $dnode3Vnodes != 2 then + goto show15 +endi +if $dnode4Vnodes != 2 then + goto show15 +endi + +print ============================== step16 +print ========= drop dnode4, create db9 + +sql drop dnode 192.168.0.4 +sleep 10000 +sql create database c_b1_d9 tables 4 +sql use c_b1_d9 +sql create table c_b1_t9 (t timestamp, i int) +sql insert into c_b1_t9 values(1520000020095, 95) +sql insert into c_b1_t9 values(1520000021094, 94) +sql insert into c_b1_t9 values(1520000022093, 93) +sql insert into c_b1_t9 values(1520000023092, 92) +sql insert into c_b1_t9 values(1520000024091, 91) + +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +$x = 0 +show16: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show16 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 1 then + goto show16 +endi +if $dnode2Vnodes != 1 then + goto show16 +endi +if $dnode3Vnodes != 1 then + goto show16 +endi + +print ============================== step17 +print ========= check data + +sql use c_b1_d1 +sql select * from c_b1_t1 +if $rows != 0 then + return -1 +endi + +sql use c_b1_d2 +sql select * from c_b1_t2 +if $rows == 0 then + return -1 +endi + +sql use c_b1_d3 +sql select * from c_b1_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $rows != 1 then + return -1 +endi +if $data01 != 36 then + return -1 +endi + +sql use c_b1_d4 +sql select * from c_b1_t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +sql use c_b1_d5 +sql select * from c_b1_t5 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi + +sql use c_b1_d6 +sql select * from c_b1_t6 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 61 then + return -1 +endi +if $data11 != 62 then + return -1 +endi +if $data21 != 63 then + return -1 +endi +if $data31 != 64 then + return -1 +endi +if $data41 != 65 then + return -1 +endi + +sql use c_b1_d7 +sql select * from c_b1_t7 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 71 then + return -1 +endi +if $data11 != 72 then + return -1 +endi +if $data21 != 73 then + return -1 +endi +if $data31 != 74 then + return -1 +endi +if $data41 != 75 then + return -1 +endi + +sql use c_b1_d8 +sql select * from c_b1_t8 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 81 then + return -1 +endi +if $data11 != 82 then + return -1 +endi +if $data21 != 83 then + return -1 +endi +if $data31 != 84 then + return -1 +endi +if $data41 != 85 then + return -1 +endi + +sql use c_b1_d9 +sql select * from c_b1_t9 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 91 then + return -1 +endi +if $data11 != 92 then + return -1 +endi +if $data21 != 93 then + return -1 +endi +if $data31 != 94 then + return -1 +endi +if $data41 != 95 then + return -1 +endi + + +print ============================================ over +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode3 -s stop -x SIGINT +#system sh/exec.sh -n dnode4 -s stop -x SIGINT +#system sh/exec.sh -n dnode5 -s stop -x SIGINT + + + diff --git a/tests/script/unique/cluster/balance1_bug.sim b/tests/script/unique/cluster/balance1_bug.sim new file mode 100644 index 0000000000..85b38d6c7e --- /dev/null +++ b/tests/script/unique/cluster/balance1_bug.sim @@ -0,0 +1,800 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database c_b1_d1 tables 4 +sql use c_b1_d1 + +sql create table c_b1_t1 (t timestamp, i int) +sql insert into c_b1_t1 values(now+1s, 15) +sql insert into c_b1_t1 values(now+2s, 14) +sql insert into c_b1_t1 values(now+2s, 13) +sql insert into c_b1_t1 values(now+3s, 12) +sql insert into c_b1_t1 values(now+4s, 11) + +sql create database c_b1_d2 tables 4 +sql use c_b1_d2 +sql create table c_b1_t2 (t timestamp, i int) +sql insert into c_b1_t2 values(now+1s, 25) +sql insert into c_b1_t2 values(now+2s, 24) +sql insert into c_b1_t2 values(now+3s, 23) +sql insert into c_b1_t2 values(now+4s, 22) +sql insert into c_b1_t2 values(now+5s, 21) + +sql show dnodes +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + return -1 +endi +if $dnode2Vnodes != null then + return -1 +endi + +print ============================== step2 +print ========= start dnode2 +sleep 2000 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 5000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 3 then + goto show2 +endi +if $dnode2Vnodes != 3 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step3 +print ========= add db3 +sql create database c_b1_d3 tables 4 +sql use c_b1_d3 +sql create table c_b1_t3 (t timestamp, i int) +sql insert into c_b1_t3 values(now+1s, 35) +sql insert into c_b1_t3 values(now+2s, 34) +sql insert into c_b1_t3 values(now+3s, 33) +sql insert into c_b1_t3 values(now+4s, 32) +sql insert into c_b1_t3 values(now+5s, 31) + +print ============================== step4 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 1 then + goto show4 +endi +if $dnode2Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step5 +print ========= add dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show5 +endi +if $dnode2Vnodes != 3 then + goto show5 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step6 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != null then + goto show6 +endi +if $dnode2Vnodes != 1 then + goto show6 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step7 +print ========= add dnode1 +sql create dnode 192.168.0.1 +sleep 23000 +system sh/exec.sh -n dnode1 -s start +sleep 14000 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 3 then + goto show7 +endi +if $dnode2Vnodes != 2 then + goto show7 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step8 +print ========= drop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +print stop dnode2 and sleep 10000 +sleep 20000 +sql drop dnode 192.168.0.2 +print drop dnode2 and sleep 9000 +sleep 19000 + +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 1 then + goto show8 +endi +if $dnode2Vnodes != null then + goto show8 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi + +print ============================== step9 +print ========= add dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show9 +endi +if $dnode2Vnodes != 3 then + goto show9 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step10 +print ========= add db4 +sql create database c_b1_d4 tables 4 +sql use c_b1_d4 +sql create table c_b1_t4 (t timestamp, i int) +sql insert into c_b1_t4 values(now+1s, 45) +sql insert into c_b1_t4 values(now+2s, 44) +sql insert into c_b1_t4 values(now+3s, 43) +sql insert into c_b1_t4 values(now+4s, 42) +sql insert into c_b1_t4 values(now+5s, 41) + +$x = 0 +show10: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show10 +endi +if $dnode2Vnodes != 2 then + goto show10 +endi + +sql use c_b1_d3 +sql insert into c_b1_t3 values(now+1s, 35) + +sql use c_b1_d2 +sql insert into c_b1_t2 values(now+1s, 25) + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role + +if $dnode1Role != master then + return -1 +endi + +print ============================== step11 +print ========= drop dnode2 +sleep 2000 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show11: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show11 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show11 +endi +if $dnode2Vnodes != null then + goto show11 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step12 +print ========= add db5 +sql create database c_b1_d5 tables 4 +sql use c_b1_d5 +sql create table c_b1_t5 (t timestamp, i int) -x error3 +print no enough vnodes, but create success +return -1 +error3: + +print ============================== step13 +print ========= add dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sql use c_b1_d5; +$x = 0 +create5: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql create table c_b1_t5 (t timestamp, i int) -x create5 +sql insert into c_b1_t5 values(now+1s, 55) +sql insert into c_b1_t5 values(now+2s, 54) +sql insert into c_b1_t5 values(now+3s, 53) +sql insert into c_b1_t5 values(now+4s, 52) +sql insert into c_b1_t5 values(now+5s, 51) + +sql create database c_b1_d6 +sql use c_b1_d6 +$x = 0 +create6: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql create table c_b1_t6 (t timestamp, i int) -x create6 +sql insert into c_b1_t6 values(now+1s, 65) +sql insert into c_b1_t6 values(now+2s, 64) +sql insert into c_b1_t6 values(now+3s, 63) +sql insert into c_b1_t6 values(now+4s, 62) +sql insert into c_b1_t6 values(now+5s, 61) + +sql show dnodes +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +#if $dnode1Vnodes != 1 then +# return -1 +#endi +#if $dnode2Vnodes != 1 then +# return -1 +#endi + +print ============================== step14 +print ========= add dnode3 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sleep 2000 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 15000 + +$x = 0 +show14: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show14 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show14 +endi +if $dnode2Vnodes != 2 then + goto show14 +endi +if $dnode3Vnodes != 2 then + goto show14 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +print ============================== step15 +print ========= create db7 db8 + +sql create database c_b1_d7 tables 4 +sql use c_b1_d7 +sql create table c_b1_t7 (t timestamp, i int) +sql insert into c_b1_t7 values(now+1s, 75) +sql insert into c_b1_t7 values(now+2s, 74) +sql insert into c_b1_t7 values(now+3s, 73) +sql insert into c_b1_t7 values(now+4s, 72) +sql insert into c_b1_t7 values(now+5s, 71) + +sql create database c_b1_d8 +sql use c_b1_d8 +sql create table c_b1_t8 (t timestamp, i int) +sql insert into c_b1_t8 values(now+1s, 85) +sql insert into c_b1_t8 values(now+2s, 84) +sql insert into c_b1_t8 values(now+3s, 83) +sql insert into c_b1_t8 values(now+4s, 82) +sql insert into c_b1_t8 values(now+5s, 81) + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ========== add dnode4 +sleep 2000 +sql create dnode 192.168.0.4 +print sql create dnode 192.168.0.4 over +system sh/exec.sh -n dnode4 -s start +print sleep 12000 +sleep 12000 +print sleep 12000 over + +$x = 0 +show15: + $x = $x + 1 + sleep 2000 + if $x == 15 then + return -1 + endi +sql show dnodes -x show15 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show15 +endi +if $dnode2Vnodes != 2 then + goto show15 +endi +if $dnode3Vnodes != 2 then + goto show15 +endi +if $dnode4Vnodes != 2 then + goto show15 +endi + +print ============================== step16 +print ========= drop dnode4, create db9 + +sql drop dnode 192.168.0.4 +sleep 10000 +sql create database c_b1_d9 tables 4 +sql use c_b1_d9 +sql create table c_b1_t9 (t timestamp, i int) +sql insert into c_b1_t9 values(now+1s, 95) +sql insert into c_b1_t9 values(now+2s, 94) +sql insert into c_b1_t9 values(now+3s, 93) +sql insert into c_b1_t9 values(now+4s, 92) +sql insert into c_b1_t9 values(now+5s, 91) + +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +$x = 0 +show16: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show16 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 1 then + goto show16 +endi +if $dnode2Vnodes != 1 then + goto show16 +endi +if $dnode3Vnodes != 1 then + goto show16 +endi + +print ============================== step17 +print ========= check data + +sleep 2000 + +sql use c_b1_d1 +sql select * from c_b1_t1 order by t desc -x s1 +s1: + +sql use c_b1_d2 +sql select * from c_b1_t2 order by t desc -x s2 +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 25 then + return -1 +endi + +if $data11 != 21 then + return -1 +endi +if $data21 != 22 then + return -1 +endi +if $data31 != 23 then + return -1 +endi +if $data41 != 24 then + return -1 +endi +s2: + +sql use c_b1_d3 +sql select * from c_b1_t3 order by t desc -x s3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 35 then + return -1 +endi +s3: + +sql use c_b1_d4 +sql select * from c_b1_d4.c_b1_t4 order by t desc -x s4 +print $data01 $data11 $data21 $data31 $data41 +s4: + + +sql use c_b1_d5 +sql select * from c_b1_d5.c_b1_t5 order by t desc -x s5 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi +s5: + +sql use c_b1_d6 +sql select * from c_b1_d6.c_b1_t6 order by t desc -x s6 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 61 then + return -1 +endi +if $data11 != 62 then + return -1 +endi +if $data21 != 63 then + return -1 +endi +if $data31 != 64 then + return -1 +endi +if $data41 != 65 then + return -1 +endi +s6: + +sql use c_b1_d7 +sql select * from c_b1_d7.c_b1_t7 order by t desc -x s7 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 71 then + return -1 +endi +if $data11 != 72 then + return -1 +endi +if $data21 != 73 then + return -1 +endi +if $data31 != 74 then + return -1 +endi +if $data41 != 75 then + return -1 +endi +s7: + +sql use c_b1_d9 +sql select * from c_b1_t9 order by t desc -x s8 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 91 then + return -1 +endi +if $data11 != 92 then + return -1 +endi +if $data21 != 93 then + return -1 +endi +if $data31 != 94 then + return -1 +endi +if $data41 != 95 then + return -1 +endi +s8: + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT + + + diff --git a/tests/script/unique/cluster/balance1_single.sim b/tests/script/unique/cluster/balance1_single.sim new file mode 100644 index 0000000000..497352544d --- /dev/null +++ b/tests/script/unique/cluster/balance1_single.sim @@ -0,0 +1,729 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode5 -c secondIp -v 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode5 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode5 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 4 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode2Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode3Vnodes + +if $dnode1Vnodes != 4 then + goto show1 +endi +if $dnode2Vnodes != 4 then + goto show1 +endi +sleep 1000 + +sql create database c_b1_d1 tables 4 +sql use c_b1_d1 + +sql create table c_b1_t1 (t timestamp, i int) +sql insert into c_b1_t1 values(now+1s, 15) +sql insert into c_b1_t1 values(now+2s, 14) +sql insert into c_b1_t1 values(now+2s, 13) +sql insert into c_b1_t1 values(now+3s, 12) +sql insert into c_b1_t1 values(now+4s, 11) + +sql create database c_b1_d2 tables 4 +sql use c_b1_d2 +sql create table c_b1_t2 (t timestamp, i int) +sql insert into c_b1_t2 values(now+1s, 25) +sql insert into c_b1_t2 values(now+2s, 24) +sql insert into c_b1_t2 values(now+3s, 23) +sql insert into c_b1_t2 values(now+4s, 22) +sql insert into c_b1_t2 values(now+5s, 21) + +sql show dnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 2 then + return -1 +endi +if $dnode3Vnodes != null then + return -1 +endi + +print ============================== step2 +print ========= start dnode3 +sleep 3000 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show2 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 3 then + goto show2 +endi +if $dnode3Vnodes != 3 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step3 +print ========= add db3 +sql create database c_b1_d3 tables 4 +sql use c_b1_d3 +sql create table c_b1_t3 (t timestamp, i int) +sql insert into c_b1_t3 values(now+1s, 35) +sql insert into c_b1_t3 values(now+2s, 34) +sql insert into c_b1_t3 values(now+3s, 33) +sql insert into c_b1_t3 values(now+4s, 32) +sql insert into c_b1_t3 values(now+5s, 31) + + +print ============================== step4 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show4: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show4 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 1 then + goto show4 +endi +if $dnode3Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step5 +print ========= add dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show5 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 2 then + goto show5 +endi +if $dnode3Vnodes != 3 then + goto show5 +endi + +print ============================== step6 +print ========= drop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +print stop dnode2 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.2 +print drop dnode2 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show6 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != null then + goto show6 +endi +if $dnode3Vnodes != 1 then + goto show6 +endi + +#only c_b2_d2 has data, c_b1_d1 and c_b1_d3 is null + +print ============================== step7 +print ========= add dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +$x = 0 +show7: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show7 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 3 then + goto show7 +endi +if $dnode3Vnodes != 2 then + goto show7 +endi + +print ============================== step8 +print ========= drop dnode3 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +print stop dnode3 and sleep 10000 +sleep 10000 +sql drop dnode 192.168.0.3 +print drop dnode3 and sleep 9000 +sleep 9000 + +$x = 0 +show8: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show8 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 1 then + goto show8 +endi +if $dnode3Vnodes != null then + goto show8 +endi + +print ============================== step9 +print ========= add dnode3 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 9000 + +$x = 0 +show9: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show9 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 2 then + goto show9 +endi +if $dnode3Vnodes != 3 then + goto show9 +endi + +print ============================== step10 +print ========= add db4 +sql create database c_b1_d4 tables 4 +sql use c_b1_d4 +sql create table c_b1_t4 (t timestamp, i int) +sql insert into c_b1_t4 values(now+1s, 45) +sql insert into c_b1_t4 values(now+2s, 44) +sql insert into c_b1_t4 values(now+3s, 43) +sql insert into c_b1_t4 values(now+4s, 42) +sql insert into c_b1_t4 values(now+5s, 41) + +$x = 0 +show10: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show10 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 2 then + goto show10 +endi +if $dnode3Vnodes != 2 then + goto show10 +endi + +sql use c_b1_d3 +sql insert into c_b1_t3 values(now+1s, 35) + +sql use c_b1_d2 +sql insert into c_b1_t2 values(now+1s, 25) + +print ============================== step11 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show11: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show11 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode2Vnodes != 0 then + goto show11 +endi +if $dnode3Vnodes != null then + goto show11 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ============================== step12 +print ========= add db5 +sql create database c_b1_d5 tables 4 +sql use c_b1_d5 + +print ============================== step13 +print ========= add dnode3 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 9000 + +sql use c_b1_d5; +$x = 0 +create5: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql create table c_b1_t5 (t timestamp, i int) -x create5 +sql insert into c_b1_t5 values(now+1s, 55) +sql insert into c_b1_t5 values(now+2s, 54) +sql insert into c_b1_t5 values(now+3s, 53) +sql insert into c_b1_t5 values(now+4s, 52) +sql insert into c_b1_t5 values(now+5s, 51) + +sql create database c_b1_d6 tables 4 +sql use c_b1_d6 +$x = 0 +create6: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table c_b1_t6 (t timestamp, i int) -x create6 +sql insert into c_b1_t6 values(now+1s, 65) +sql insert into c_b1_t6 values(now+2s, 64) +sql insert into c_b1_t6 values(now+3s, 63) +sql insert into c_b1_t6 values(now+4s, 62) +sql insert into c_b1_t6 values(now+5s, 61) + +sql show dnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +#if $dnode2Vnodes != 1 then +# return -1 +#endi +#if $dnode3Vnodes != 1 then +# return -1 +#endi + +print ============================== step14 +print ========= add dnode4 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 10000 + +$x = 0 +show14: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show14 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode2Vnodes != 2 then + goto show14 +endi +if $dnode3Vnodes != 2 then + goto show14 +endi +if $dnode4Vnodes != 2 then + goto show14 +endi + +print ============================== step15 +print ========= create db7 db8 + +sql create database c_b1_d7 tables 4 +sql use c_b1_d7 +sql create table c_b1_t7 (t timestamp, i int) +sql insert into c_b1_t7 values(now+1s, 75) +sql insert into c_b1_t7 values(now+2s, 74) +sql insert into c_b1_t7 values(now+3s, 73) +sql insert into c_b1_t7 values(now+4s, 72) +sql insert into c_b1_t7 values(now+5s, 71) + +sql create database c_b1_d8 tables 4 +sql use c_b1_d8 +sql create table c_b1_t8 (t timestamp, i int) +sql insert into c_b1_t8 values(now+1s, 85) +sql insert into c_b1_t8 values(now+2s, 84) +sql insert into c_b1_t8 values(now+3s, 83) +sql insert into c_b1_t8 values(now+4s, 82) +sql insert into c_b1_t8 values(now+5s, 81) + + +print ========== add dnode5 +sql create dnode 192.168.0.5 +print sql create dnode 192.168.0.5 over +system sh/exec.sh -n dnode5 -s start +print sleep 12000 +sleep 12000 +print sleep 12000 over + +$x = 0 +show15: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show15 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode2Vnodes != 2 then + goto show15 +endi +if $dnode3Vnodes != 2 then + goto show15 +endi +if $dnode4Vnodes != 2 then + goto show15 +endi +if $dnode5Vnodes != 2 then + goto show15 +endi + +print ============================== step16 +print ========= drop dnode5, create db9 + +sql drop dnode 192.168.0.5 +sleep 10000 +sql create database c_b1_d9 tables 4 +sql use c_b1_d9 +sql create table c_b1_t9 (t timestamp, i int) +sql insert into c_b1_t9 values(now+1s, 95) +sql insert into c_b1_t9 values(now+2s, 94) +sql insert into c_b1_t9 values(now+3s, 93) +sql insert into c_b1_t9 values(now+4s, 92) +sql insert into c_b1_t9 values(now+5s, 91) + +system sh/exec.sh -n dnode5 -s stop -x SIGINT + +$x = 0 +show16: + $x = $x + 1 + sleep 1000 + if $x == 50 then + return -1 + endi +sql show dnodes -x show16 +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode2Vnodes != 1 then + goto show16 +endi +if $dnode3Vnodes != 1 then + goto show16 +endi +if $dnode4Vnodes != 1 then + goto show16 +endi + +print ============================== step17 +print ========= check data + +sql use c_b1_d1 +sql select * from c_b1_t1 +if $rows != 0 then + return -1 +endi + +sql use c_b1_d2 +sql select * from c_b1_t2 +if $rows != 6 then + return -1 +endi + +sql use c_b1_d3 +sql select * from c_b1_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $rows != 1 then + return -1 +endi +if $data01 != 35 then + return -1 +endi + +sql use c_b1_d4 +sql select * from c_b1_t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +sql use c_b1_d5 +sql select * from c_b1_t5 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi + +sql use c_b1_d6 +sql select * from c_b1_t6 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 61 then + return -1 +endi +if $data11 != 62 then + return -1 +endi +if $data21 != 63 then + return -1 +endi +if $data31 != 64 then + return -1 +endi +if $data41 != 65 then + return -1 +endi + +sql use c_b1_d7 +sql select * from c_b1_t7 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 71 then + return -1 +endi +if $data11 != 72 then + return -1 +endi +if $data21 != 73 then + return -1 +endi +if $data31 != 74 then + return -1 +endi +if $data41 != 75 then + return -1 +endi + +sql use c_b1_d8 +sql select * from c_b1_t8 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 81 then + return -1 +endi +if $data11 != 82 then + return -1 +endi +if $data21 != 83 then + return -1 +endi +if $data31 != 84 then + return -1 +endi +if $data41 != 85 then + return -1 +endi + +sql use c_b1_d9 +sql select * from c_b1_t9 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 91 then + return -1 +endi +if $data11 != 92 then + return -1 +endi +if $data21 != 93 then + return -1 +endi +if $data31 != 94 then + return -1 +endi +if $data41 != 95 then + return -1 +endi + + +print ============================================ over +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode3 -s stop -x SIGINT +#system sh/exec.sh -n dnode4 -s stop -x SIGINT +#system sh/exec.sh -n dnode5 -s stop -x SIGINT + + + diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim new file mode 100644 index 0000000000..65dbfba361 --- /dev/null +++ b/tests/script/unique/cluster/balance2.sim @@ -0,0 +1,787 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up +system sh/ip.sh -i 8 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode5 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode6 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode7 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode8 -c numOfMPeers -v 3 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode5 -c clog -v 1 +system sh/cfg.sh -n dnode6 -c clog -v 1 +system sh/cfg.sh -n dnode7 -c clog -v 1 +system sh/cfg.sh -n dnode8 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 0 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 4001 +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 4001 + +sql create database c_b2_d1 replica 2 tables 4 +sql use c_b2_d1 +sql create table c_b2_t1 (t timestamp, i int) +sql insert into c_b2_t1 values(1520000020015, 15) +sql insert into c_b2_t1 values(1520000021014, 14) +sql insert into c_b2_t1 values(1520000022013, 13) +sql insert into c_b2_t1 values(1520000023012, 12) +sql insert into c_b2_t1 values(1520000024011, 11) + +sql create database c_b2_d2 replica 2 tables 4 +sql use c_b2_d2 +sql create table c_b2_t2 (t timestamp, i int) +sql insert into c_b2_t2 values(1520000020025, 25) +sql insert into c_b2_t2 values(1520000021024, 24) +sql insert into c_b2_t2 values(1520000022023, 23) +sql insert into c_b2_t2 values(1520000023022, 22) +sql insert into c_b2_t2 values(1520000024021, 21) + +sql create database c_b2_d3 replica 2 tables 4 +sql use c_b2_d3 +sql create table c_b2_t3 (t timestamp, i int) +sql insert into c_b2_t3 values(1520000020035, 35) +sql insert into c_b2_t3 values(1520000021034, 34) +sql insert into c_b2_t3 values(1520000022033, 33) +sql insert into c_b2_t3 values(1520000023032, 32) +sql insert into c_b2_t3 values(1520000024031, 31) + +$x = 0 +show1: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi + +print ============================== step2 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show2: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 1 then + goto show2 +endi +if $dnode2Vnodes != null then + goto show2 +endi +if $dnode3Vnodes != 1 then + goto show2 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step3 +print ========= start dnode2 +sql create dnode 192.168.0.2 + +sleep 3000 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +sleep 3000 + +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +$x = 0 +show3: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show3 +endi +if $dnode2Vnodes != 2 then + goto show3 +endi +if $dnode3Vnodes != 2 then + goto show3 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step4 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show4: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 1 then + goto show4 +endi +if $dnode2Vnodes != 1 then + goto show4 +endi +if $dnode3Vnodes != null then + goto show4 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ============================== step5 +print ========= start dnode3 +sql create dnode 192.168.0.3 + +sleep 3000 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +sleep 3000 + +system sh/exec.sh -n dnode3 -s start +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show5 +endi +if $dnode2Vnodes != 2 then + goto show5 +endi +if $dnode3Vnodes != 2 then + goto show5 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step6 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != null then + goto show6 +endi +if $dnode2Vnodes != 1 then + goto show6 +endi +if $dnode3Vnodes != 1 then + goto show6 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step7 +print ========= start dnode1 +sql create dnode 192.168.0.1 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sleep 3000 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +sleep 3000 + +system sh/exec.sh -n dnode1 -s start +sleep 9000 + +$x = 0 + +show7: + sql show mnodes + $dnode1Role = $data3_192.168.0.1 + $dnode2Role = $data3_192.168.0.2 + $dnode3Role = $data3_192.168.0.3 + $dnode4Role = $data3_192.168.0.4 + print 192.168.0.1 ==> $dnode1Role + print 192.168.0.2 ==> $dnode2Role + print 192.168.0.3 ==> $dnode3Role + print 192.168.0.4 ==> $dnode4Role + + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 2 then + goto show7 +endi +if $dnode2Vnodes != 2 then + goto show7 +endi +if $dnode3Vnodes != 2 then + goto show7 +endi + +print ============================== step8 +print ========= add db4 + +sql create database c_b2_d4 replica 2 tables 4 +sql use c_b2_d4 +sql create table c_b2_t4 (t timestamp, i int) +sql insert into c_b2_t4 values(1520000020045, 45) +sql insert into c_b2_t4 values(1520000021044, 44) +sql insert into c_b2_t4 values(1520000022043, 43) +sql insert into c_b2_t4 values(1520000023042, 42) +sql insert into c_b2_t4 values(1520000024041, 41) + +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 9000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show8 +endi +if $dnode2Vnodes != 2 then + goto show8 +endi +if $dnode3Vnodes != 2 then + goto show8 +endi +if $dnode4Vnodes != 2 then + goto show8 +endi + +print ============================== step9 +print ========= drop dnode1.4 +sql drop dnode 192.168.0.1 +sql drop dnode 192.168.0.4 +sleep 10000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != null then + goto show9 +endi +if $dnode2Vnodes != 0 then + goto show9 +endi +if $dnode3Vnodes != 0 then + goto show9 +endi +if $dnode4Vnodes != null then + goto show9 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +print ============================== step10 +print ========= start dnode1.4 +sql create dnode 192.168.0.1 +sql create dnode 192.168.0.4 + +sleep 3000 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +sleep 3000 + +sleep 3000 +system sh/deploy.sh -n dnode4 -m 192.168.0.2 -i 192.168.0.4 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +sleep 3000 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode4 -s start +sleep 10000 + +$x = 0 +show10: + sql show mnodes + $dnode1Role = $data3_192.168.0.1 + $dnode2Role = $data3_192.168.0.2 + $dnode3Role = $data3_192.168.0.3 + $dnode4Role = $data3_192.168.0.4 + print 192.168.0.1 ==> $dnode1Role + print 192.168.0.2 ==> $dnode2Role + print 192.168.0.3 ==> $dnode3Role + print 192.168.0.4 ==> $dnode4Role + + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show10 +endi +if $dnode2Vnodes != 2 then + goto show10 +endi +if $dnode3Vnodes != 2 then + goto show10 +endi +if $dnode4Vnodes != 2 then + goto show10 +endi + +print ============================== step11 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +sql create database c_b2_d5 replica 2 tables 4 +sql use c_b2_d5; +sql create table c_b2_t5 (t timestamp, i int) +sql insert into c_b2_t5 values(1520000020055, 55) +sql insert into c_b2_t5 values(1520000021054, 54) +sql insert into c_b2_t5 values(1520000022053, 53) +sql insert into c_b2_t5 values(1520000023052, 52) +sql insert into c_b2_t5 values(1520000024051, 51) + +sql create database c_b2_d6 replica 2 tables 4 +sql use c_b2_d6 +sql create table c_b2_t6 (t timestamp, i int) +sql insert into c_b2_t6 values(1520000020065, 65) +sql insert into c_b2_t6 values(1520000021064, 64) +sql insert into c_b2_t6 values(1520000022063, 63) +sql insert into c_b2_t6 values(1520000023062, 62) +sql insert into c_b2_t6 values(1520000024061, 61) + +$x = 0 +show11: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show11 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show11 +endi +if $dnode2Vnodes != 1 then + goto show11 +endi +if $dnode3Vnodes != 1 then + goto show11 +endi +if $dnode4Vnodes != 1 then + goto show11 +endi + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +print ============================== step12 +print ========= check data + +sql use c_b2_d1 +sql select * from c_b2_t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use c_b2_d2 +sql select * from c_b2_t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +#if $data01 != 21 then +# return -1 +#endi +#if $data11 != 22 then +# return -1 +#endi +#if $data21 != 23 then +# return -1 +#endi +#if $data31 != 24 then +# return -1 +#endi +#if $data41 != 25 then +# return -1 +#endi + +sql use c_b2_d3 +sql select * from c_b2_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql use c_b2_d4 +sql select * from c_b2_t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + +sql use c_b2_d5 +sql select * from c_b2_t5 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 51 then + return -1 +endi +if $data11 != 52 then + return -1 +endi +if $data21 != 53 then + return -1 +endi +if $data31 != 54 then + return -1 +endi +if $data41 != 55 then + return -1 +endi + +sql use c_b2_d6 +sql select * from c_b2_t6 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 61 then + return -1 +endi +if $data11 != 62 then + return -1 +endi +if $data21 != 63 then + return -1 +endi +if $data31 != 64 then + return -1 +endi +if $data41 != 65 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT + + diff --git a/tests/script/unique/cluster/balance3.sim b/tests/script/unique/cluster/balance3.sim new file mode 100644 index 0000000000..83499a4d66 --- /dev/null +++ b/tests/script/unique/cluster/balance3.sim @@ -0,0 +1,619 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up +system sh/ip.sh -i 8 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode5 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode6 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode7 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode8 -c numOfMpeers -v 3 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode5 -c clog -v 1 +system sh/cfg.sh -n dnode6 -c clog -v 1 +system sh/cfg.sh -n dnode7 -c clog -v 1 +system sh/cfg.sh -n dnode8 -c clog -v 1 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 2001 + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3001 + +sql create database c_b3_d1 replica 3 +sql use c_b3_d1 +sql create table c_b3_t1 (t timestamp, i int) +sql insert into c_b3_t1 values(1520000020015, 15) +sql insert into c_b3_t1 values(1520000021014, 14) +sql insert into c_b3_t1 values(1520000022013, 13) +sql insert into c_b3_t1 values(1520000023012, 12) +sql insert into c_b3_t1 values(1520000024011, 11) + +sql create database c_b3_d2 replica 3 +sql use c_b3_d2 +sql create table c_b3_t2 (t timestamp, i int) +sql insert into c_b3_t2 values(1520000020025, 25) +sql insert into c_b3_t2 values(1520000021024, 24) +sql insert into c_b3_t2 values(1520000022023, 23) +sql insert into c_b3_t2 values(1520000023022, 22) +sql insert into c_b3_t2 values(1520000024021, 21) + +sql create database c_b3_d3 replica 3 +sql use c_b3_d3 +sql create table c_b3_t3 (t timestamp, i int) +sql insert into c_b3_t3 values(1520000020035, 35) +sql insert into c_b3_t3 values(1520000021034, 34) +sql insert into c_b3_t3 values(1520000022033, 33) +sql insert into c_b3_t3 values(1520000023032, 32) +sql insert into c_b3_t3 values(1520000024031, 31) + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show1 +endi +if $dnode2Vnodes != 1 then + goto show1 +endi +if $dnode3Vnodes != 1 then + goto show1 +endi +if $dnode4Vnodes != null then + goto show1 +endi + +print ============================== step2 +print ========= start dnode4 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 9000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode4Vnodes != 2 then + goto show2 +endi + +print ============================== step3 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 9000 + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show3 +endi +if $dnode2Vnodes != null then + goto show3 +endi +if $dnode3Vnodes != 1 then + goto show3 +endi +if $dnode4Vnodes != 1 then + goto show3 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ============================== step4 +print ========= start dnode2 +sleep 3000 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode2Vnodes != 2 then + goto show4 +endi + +print ============================== step5 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 9000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show5 +endi +if $dnode2Vnodes != 1 then + goto show5 +endi +if $dnode3Vnodes != null then + goto show5 +endi +if $dnode4Vnodes != 1 then + goto show5 +endi + + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ============================== step6 +print ========= start dnode3 +sleep 3000 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode3Vnodes != 2 then + goto show6 +endi + +print ============================== step7 +print ========= drop dnode4 +sql drop dnode 192.168.0.4 +sleep 9000 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show7 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show7 +endi +if $dnode2Vnodes != 1 then + goto show7 +endi +if $dnode3Vnodes != 1 then + goto show7 +endi +if $dnode4Vnodes != null then + goto show7 +endi + +system sh/exec.sh -n dnode4 -s stop -x SIGINT + +print ============================== step8 +print ========= start dnode4 +sleep 3000 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 9000 + +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show8 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode4Vnodes != 2 then + goto show8 +endi + +print ============================== step9 +print ========= drop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show9 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != null then + goto show9 +endi +if $dnode2Vnodes != 1 then + goto show9 +endi +if $dnode3Vnodes != 1 then + goto show9 +endi +if $dnode4Vnodes != 1 then + goto show9 +endi + +print ============================== step10 +print ========= start dnode1 +sleep 3000 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +sleep 3000 +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 9000 + +$x = 0 +show10: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show10 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 2 then + goto show10 +endi + +print ============================== step11 +print ========= add db4 + +sql create database c_b3_d4 replica 3 +sql use c_b3_d4 +$x = 0 +create4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql create table c_b3_t4 (t timestamp, i int) -x create4 +sql insert into c_b3_t4 values(1520000020045, 45) +sql insert into c_b3_t4 values(1520000021044, 44) +sql insert into c_b3_t4 values(1520000022043, 43) +sql insert into c_b3_t4 values(1520000023042, 42) +sql insert into c_b3_t4 values(1520000024041, 41) +sleep 9000 + +$x = 0 +show11: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show11 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != 1 then + goto show11 +endi +if $dnode2Vnodes != 1 then + goto show11 +endi +#if $dnode3Vnodes != 1 then +# goto show11 +#endi +#if $dnode4Vnodes != 1 then +# goto show11 +#endi + +print ============================== step12 +print ========= drop dnode1 +sql drop dnode 192.168.0.1 +sleep 10000 + +$x = 0 +show12: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes -x show12 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes + +if $dnode1Vnodes != null then + goto show12 +endi +if $dnode2Vnodes != 0 then + goto show12 +endi +if $dnode3Vnodes != 0 then + goto show12 +endi +if $dnode4Vnodes != 0 then + goto show12 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +print ============================== step13 +print ========= check data + +sql use c_b3_d1 +sql select * from c_b3_t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use c_b3_d2 +sql select * from c_b3_t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use c_b3_d3 +sql select * from c_b3_t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql use c_b3_d4 +sql select * from c_b3_t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT + + diff --git a/tests/script/unique/cluster/testSuite.sim b/tests/script/unique/cluster/testSuite.sim new file mode 100644 index 0000000000..321ff9a2a9 --- /dev/null +++ b/tests/script/unique/cluster/testSuite.sim @@ -0,0 +1,5 @@ +run cluster/cluster/balance1.sim +run cluster/cluster/balance2.sim +run cluster/cluster/balance3.sim +run cluster/cluster/balance1_bug.sim +run cluster/cluster/balance1_single.sim \ No newline at end of file diff --git a/tests/script/unique/column/replica3.sim b/tests/script/unique/column/replica3.sim new file mode 100644 index 0000000000..2ec7879615 --- /dev/null +++ b/tests/script/unique/column/replica3.sim @@ -0,0 +1,39 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +sql create database db replica 3 +sql use db +sql create table mt (ts timestamp, f1 float, f2 float, f3 float, f4 float, f5 float, f6 float, f7 float, f8 float, f9 float, f10 float) tags (t1 int, t2 int) +sql create table tb1 using mt tags(1, 2) +sleep 3001 + +$x = 1000 +while $x < 2000 + sql insert into tb1 values (now+1s , $x , $x , $x , $x , $x , $x , $x , $x , $x , $x ) + $x = $x + 1 +endw + + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop + + diff --git a/tests/script/unique/column/testSuite.sim b/tests/script/unique/column/testSuite.sim new file mode 100644 index 0000000000..2926157a44 --- /dev/null +++ b/tests/script/unique/column/testSuite.sim @@ -0,0 +1 @@ +run cluster/column/replica3.sim diff --git a/tests/script/unique/db/back_insert.sim b/tests/script/unique/db/back_insert.sim new file mode 100644 index 0000000000..43831cca95 --- /dev/null +++ b/tests/script/unique/db/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim new file mode 100644 index 0000000000..7111574081 --- /dev/null +++ b/tests/script/unique/db/commit.sim @@ -0,0 +1,120 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +print ========= start other dnodes +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step1 create db +sql create database commitdb replica 1 days 7 keep 30 +sql use commitdb +sql create table tb (ts timestamp, i int) + +$x = 1 +while $x < 41 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step2 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != 40 then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +$oldnum = $rows +$num = $rows + 2 + +print ======== step3 import old data +sql import into tb values (now - 10d , -10 ) + +sql import into tb values (now - 11d , -11 ) + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step4 import new data +sql_error import into tb values (now + 30d , 30 ) +sql_error import into tb values (now + 31d , 31 ) + +sql select * from tb order by ts desc +print ===> rows $rows +print ===> last $data01 + +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + +print ======== step5 stop dnode +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql select * from tb +print ===> rows $rows +print ===> last $data01 + +sql select * from tb order by ts desc +if $rows != $num then + return -1 +endi +if $data01 != 40 then + return -1 +endi + diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim new file mode 100644 index 0000000000..ab44841522 --- /dev/null +++ b/tests/script/unique/db/delete.sim @@ -0,0 +1,49 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c clog -v 0 +system sh/cfg.sh -n dnode2 -c clog -v 0 +system sh/cfg.sh -n dnode3 -c clog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode1 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode2 -c cacheBlockSize -v 200 +system sh/cfg.sh -n dnode3 -c cacheBlockSize -v 200 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step1 +sql create database db replica 3 ablocks 2 tblocks 5 tables 10000 +sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$tbPrefix = db.t +$i = 0 +while $i < 100000 + $tb = $tbPrefix . $i + sql create table $tb using db.mt tags( $i ) + $i = $i + 1 +endw + +print ======== step2 +sleep 1000 +sql drop database db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/unique/db/delete_part.sim b/tests/script/unique/db/delete_part.sim new file mode 100644 index 0000000000..0a03bc558c --- /dev/null +++ b/tests/script/unique/db/delete_part.sim @@ -0,0 +1,79 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c tables -v 4 +system sh/cfg.sh -n dnode2 -c tables -v 4 +system sh/cfg.sh -n dnode3 -c tables -v 4 +system sh/cfg.sh -n dnode4 -c tables -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +$loop = 0 +begin: + + $db = db . $loop + + print ======== step1 + sql create database $db + sql use $db + + $x = 0 + while $x < 32 + $tb = tb . $x + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + $x = $x + 1 + endw + + print ======== step2 + system sh/exec.sh -n dnode2 -s stop + sql drop database $db + + + print ======== step3 + sleep 3000 + system sh/exec.sh -n dnode2 -s start + sleep 20000 + + print ===> test times : $loop + if $loop > 5 then + return 0 + endi + + $loop = $loop + 1 + +goto begin + diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim new file mode 100644 index 0000000000..6ef47132c2 --- /dev/null +++ b/tests/script/unique/db/replica_add12.sim @@ -0,0 +1,232 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode4 -c commitLog -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +sleep 2000 + +print ======== step2 +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 +sleep 22000 + +print ======== step3 +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 +print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 +print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 + +if $data2_192.168.0.1 != 0 then + goto show3 +endi + +if $data3_192.168.0.1 != 4 then + goto show3 +endi + +if $data3_192.168.0.2 != 0 then + goto show3 +endi + +if $data3_192.168.0.3 != 0 then + goto show3 +endi + +print ======== step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +sleep 20000 +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start +sleep 10000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 10000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start +sleep 10000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 10000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/db/replica_add13.sim b/tests/script/unique/db/replica_add13.sim new file mode 100644 index 0000000000..ff8e73e97a --- /dev/null +++ b/tests/script/unique/db/replica_add13.sim @@ -0,0 +1,268 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode4 -c commitLog -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 1 +sql create database d2 replica 1 +sql create database d3 replica 1 +sql create database d4 replica 1 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql alter database d1 replica 3 +sql alter database d2 replica 3 +sql alter database d3 replica 3 +sql alter database d4 replica 3 +sleep 12000 + +print ======== step3 +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 +print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 +print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 +print dnode192.168.0.4 ==> openVnodes: $data2_192.168.0.4 freeVnodes: $data3_192.168.0.4 + +if $data2_192.168.0.1 != 0 then + goto show3 +endi + +if $data3_192.168.0.1 != 4 then + goto show3 +endi + +if $data3_192.168.0.2 != 0 then + goto show3 +endi + +if $data3_192.168.0.3 != 0 then + goto show3 +endi + +if $data3_192.168.0.4 != 0 then + goto show3 +endi + +print ======== step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step5 +sleep 10000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + +print ========= step8 +system sh/exec.sh -n dnode4 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 6) +sql insert into d2.t2 values(now, 6) +sql insert into d3.t3 values(now, 6) +sql insert into d4.t4 values(now, 6) + +sql select * from d1.t1 +if $rows != 6 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 6 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 6 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 6 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/db/replica_add23.sim b/tests/script/unique/db/replica_add23.sim new file mode 100644 index 0000000000..d839efa82b --- /dev/null +++ b/tests/script/unique/db/replica_add23.sim @@ -0,0 +1,280 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode4 -c commitLog -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 +sql alter database d1 replica 3 +sql alter database d2 replica 3 +sql alter database d3 replica 3 +sql alter database d4 replica 3 +sleep 12000 + +print ======== step3 +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 +print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 +print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 +print dnode192.168.0.4 ==> openVnodes: $data2_192.168.0.4 freeVnodes: $data3_192.168.0.4 + +if $data2_192.168.0.1 != 0 then + goto show3 +endi + +if $data2_192.168.0.2 != 4 then + goto show3 +endi + +if $data2_192.168.0.3 != 4 then + goto show3 +endi + +if $data2_192.168.0.4 != 4 then + goto show3 +endi + +if $data3_192.168.0.1 != 4 then + goto show3 +endi + +if $data3_192.168.0.2 != 0 then + goto show3 +endi + +if $data3_192.168.0.3 != 0 then + goto show3 +endi + +if $data3_192.168.0.4 != 0 then + goto show3 +endi + +print ======== step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +sleep 10000 +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + +print ========= step8 +system sh/exec.sh -n dnode4 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 6) +sql insert into d2.t2 values(now, 6) +sql insert into d3.t3 values(now, 6) +sql insert into d4.t4 values(now, 6) + +sql select * from d1.t1 +if $rows != 6 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 6 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 6 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 6 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/db/replica_part.sim b/tests/script/unique/db/replica_part.sim new file mode 100644 index 0000000000..7753b47b4e --- /dev/null +++ b/tests/script/unique/db/replica_part.sim @@ -0,0 +1,196 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sql alter database d4 replica 2 +sleep 3000 + +print ========= step3 +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +print ========= step4 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step5 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step7 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + diff --git a/tests/script/unique/db/replica_reduce21.sim b/tests/script/unique/db/replica_reduce21.sim new file mode 100644 index 0000000000..e79aedbb24 --- /dev/null +++ b/tests/script/unique/db/replica_reduce21.sim @@ -0,0 +1,152 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ======== step2 create d5 +sql create database d5 replica 1 +sql create table d5.t5 (ts timestamp, i int) -x error1 + return -1 +error1: + +print ========= step3 alter d1 +sql alter database d1 replica 1 +sleep 8000 + +print ========= step4 query d1 +sql insert into d1.t1 values(now, 2) +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +print ========= step5 query d5 +sql create table d5.t5 (ts timestamp, i int) +sql insert into d5.t5 values(now, 1); +sql select * from d5.t5 +if $rows != 1 then + return -1 +endi + +print ========= step6 alter d5 +sql alter database d5 replica 2 -x error2 + return -1 +error2: + +print ========= step7 drop d1 +sql drop database d1 +sleep 12000 + +print ========= step8 +sql insert into d5.t5 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d5.t5 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ======== step9 stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d5.t5 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d5.t5 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi diff --git a/tests/script/unique/db/replica_reduce31.sim b/tests/script/unique/db/replica_reduce31.sim new file mode 100644 index 0000000000..92da979b97 --- /dev/null +++ b/tests/script/unique/db/replica_reduce31.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +sql alter database d1 replica 1 +sql alter database d2 replica 1 +sql alter database d3 replica 1 +sleep 12000 + +print ========= step3 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step4 alter db +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sleep 12000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + + +print ========= step5 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi + + +print ========= step6 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 +sql insert into d1.t1 values(now, 6) +sql insert into d2.t2 values(now, 6) +sql insert into d3.t3 values(now, 6) +sql insert into d4.t4 values(now, 6) + +sql select * from d1.t1 +if $rows != 6 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 6 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 6 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 6 then + return -1 +endi diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim new file mode 100644 index 0000000000..86f99e72be --- /dev/null +++ b/tests/script/unique/db/replica_reduce32.sim @@ -0,0 +1,188 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ======== step1 +sql create database d1 replica 3 +sql create database d2 replica 3 +sql create database d3 replica 3 +sql create database d4 replica 3 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d2.t2 values(now, 1) +sql insert into d1.t1 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +print ========= step2 alter db +sql alter database d1 replica 2 +sql alter database d2 replica 2 +sql alter database d3 replica 2 +sleep 12000 + +print ========= step3 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step4 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step5 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step6 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi diff --git a/tests/script/unique/db/testSuite.sim b/tests/script/unique/db/testSuite.sim new file mode 100644 index 0000000000..27bd24d9dc --- /dev/null +++ b/tests/script/unique/db/testSuite.sim @@ -0,0 +1,10 @@ +#run cluster/db/commit.sim +run cluster/db/delete.sim +run cluster/db/replica_add12.sim +run cluster/db/replica_add13.sim +run cluster/db/replica_add23.sim +run cluster/db/replica_reduce21.sim +run cluster/db/replica_reduce32.sim +run cluster/db/replica_reduce31.sim +run cluster/db/replica_part.sim +run cluster/db/delete_part.sim diff --git a/tests/script/unique/dnode/backup/balance4.sim b/tests/script/unique/dnode/backup/balance4.sim new file mode 100644 index 0000000000..914f254ef2 --- /dev/null +++ b/tests/script/unique/dnode/backup/balance4.sim @@ -0,0 +1,435 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode5 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode6 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode7 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 +system sh/cfg.sh -n dnode5 -c statusInterval -v 1 +system sh/cfg.sh -n dnode6 -c statusInterval -v 1 +system sh/cfg.sh -n dnode7 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode7 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode7 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 +system sh/cfg.sh -n dnode6 -c commitLog -v 0 +system sh/cfg.sh -n dnode7 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 4 + +print ============================ step1 +print ========= start dnode1-5 +system sh/exec.sh -n dnode1 -s start +sleep 4001 +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 4001 +$x = 0 +created1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create database d_b4_d1 replica 4 -x created1 +sql use d_b4_d1 + +create1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create table d_b4_d1 (t timestamp, i int) -x create1 +sql insert into d_b4_d1 values(now+1s, 15) +sql insert into d_b4_d1 values(now+2s, 14) +sql insert into d_b4_d1 values(now+2s, 13) +sql insert into d_b4_d1 values(now+3s, 12) +sql insert into d_b4_d1 values(now+4s, 11) + +sql create database d_b4_d2 replica 4 +sql use d_b4_d2 + +create2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create table d_b4_d2 (t timestamp, i int) -x create2 +sql insert into d_b4_d2 values(now+1s, 25) +sql insert into d_b4_d2 values(now+2s, 24) +sql insert into d_b4_d2 values(now+3s, 23) +sql insert into d_b4_d2 values(now+4s, 22) +sql insert into d_b4_d2 values(now+5s, 21) + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 4 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi +if $dnode4Vnodes != 2 then + goto show1 +endi +if $dnode5Vnodes != 2 then + goto show1 +endi + +print ============================ step2 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 7000 +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode3Vnodes != 2 then + goto show2 +endi +if $dnode4Vnodes != 2 then + goto show2 +endi +if $dnode5Vnodes != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop + +print ============================ step3 +print ========= start dnode6 +sql create dnode 192.168.0.6 +system sh/exec.sh -n dnode6 -s start +sleep 4000 +$x = 0 +show3: + $x = $x + 1 + sleep 6000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != 4 then + goto show3 +endi +if $dnode3Vnodes != 2 then + goto show3 +endi +if $dnode4Vnodes != 2 then + goto show3 +endi +if $dnode5Vnodes != 2 then + goto show3 +endi +if $dnode6Vnodes != 2 then + goto show3 +endi + +print ============================ step4 +print ========= add db3 +sql create database d_b4_d3 replica 4 +sql use d_b4_d3 + +create3: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table d_b4_d3 (t timestamp, i int) -x create3 +sql insert into d_b4_d3 values(now+1s, 35) +sql insert into d_b4_d3 values(now+2s, 34) +sql insert into d_b4_d3 values(now+3s, 33) +sql insert into d_b4_d3 values(now+4s, 32) +sql insert into d_b4_d3 values(now+5s, 31) + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != 4 then + goto show4 +endi +if $dnode3Vnodes != 1 then + goto show4 +endi +if $dnode4Vnodes != 1 then + goto show4 +endi +if $dnode5Vnodes != 1 then + goto show4 +endi +if $dnode6Vnodes != 1 then + goto show4 +endi + +print ============================ step5 +print ========= start dnode7 +sql create dnode 192.168.0.7 +system sh/exec.sh -n dnode7 -s start +sleep 7000 +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode7Vnodes = $data3_192.168.0.7 +print 192.168.0.7 $dnode7Vnodes + +if $dnode1Vnodes != 4 then + goto show5 +endi +if $dnode7Vnodes != 2 then + goto show5 +endi + +print ============================ step6 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 7000 +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes +$dnode7Vnodes = $data3_192.168.0.7 +print 192.168.0.7 $dnode7Vnodes + +if $dnode1Vnodes != 4 then + goto show6 +endi +if $dnode4Vnodes != 1 then + goto show6 +endi +if $dnode5Vnodes != 1 then + goto show6 +endi +if $dnode6Vnodes != 1 then + goto show6 +endi +if $dnode7Vnodes != 1 then + goto show6 +endi + +system sh/exec.sh -n dnode3 -s stop + +return +print ============================ step7 +print ========= check data + +sql use d_b4_d1 +sql select * from d_b4_d1 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use d_b4_d2 +sql select * from d_b4_d2 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use d_b4_d3 +sql select * from d_b4_d3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop +system sh/exec.sh -n dnode7 -s stop diff --git a/tests/script/unique/dnode/backup/balance5.sim b/tests/script/unique/dnode/backup/balance5.sim new file mode 100644 index 0000000000..ac6157ca93 --- /dev/null +++ b/tests/script/unique/dnode/backup/balance5.sim @@ -0,0 +1,469 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 +system sh/deploy.sh -n dnode8 -m 192.168.0.1 -i 192.168.0.8 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode5 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode6 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode7 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode8 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 +system sh/cfg.sh -n dnode5 -c statusInterval -v 1 +system sh/cfg.sh -n dnode6 -c statusInterval -v 1 +system sh/cfg.sh -n dnode7 -c statusInterval -v 1 +system sh/cfg.sh -n dnode8 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode7 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode8 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode7 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode8 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 +system sh/cfg.sh -n dnode6 -c commitLog -v 0 +system sh/cfg.sh -n dnode7 -c commitLog -v 0 +system sh/cfg.sh -n dnode8 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode7 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode8 -c mgmtEqualVnodeNum -v 4 + +print ============================ step1 +print ========= start dnode1-5 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql connect -x connectTbase +sleep 4001 +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +sql create dnode 192.168.0.5 +sql create dnode 192.168.0.6 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +sleep 4001 +$x = 0 +created1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create database d_b5_d1 replica 5 -x created1 +sql use d_b5_d1 + +create1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create table d_b5_t1 (t timestamp, i int) -x create1 +sql insert into d_b5_t1 values(now+1s, 15) +sql insert into d_b5_t1 values(now+2s, 14) +sql insert into d_b5_t1 values(now+2s, 13) +sql insert into d_b5_t1 values(now+3s, 12) +sql insert into d_b5_t1 values(now+4s, 11) + +sql create database d_b5_d2 replica 5 +sql use d_b5_d2 +create2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi +sql create table d_b5_t2 (t timestamp, i int) -x create2 +sql insert into d_b5_t2 values(now+1s, 25) +sql insert into d_b5_t2 values(now+2s, 24) +sql insert into d_b5_t2 values(now+3s, 23) +sql insert into d_b5_t2 values(now+4s, 22) +sql insert into d_b5_t2 values(now+5s, 21) + +$x = 0 +show1: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != 4 then + goto show1 +endi +if $dnode2Vnodes != 2 then + goto show1 +endi +if $dnode3Vnodes != 2 then + goto show1 +endi +if $dnode4Vnodes != 2 then + goto show1 +endi +if $dnode5Vnodes != 2 then + goto show1 +endi +if $dnode6Vnodes != 2 then + goto show1 +endi + +print ============================ step2 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 7000 +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode3Vnodes != 2 then + goto show2 +endi +if $dnode4Vnodes != 2 then + goto show2 +endi +if $dnode5Vnodes != 2 then + goto show2 +endi +if $dnode6Vnodes != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop + +print ============================ step3 +print ========= start dnode7 +sql create dnode 192.168.0.7 +system sh/exec.sh -n dnode7 -s start +sleep 5000 +$x = 0 +show3: + $x = $x + 1 + sleep 5000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show3 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes +$dnode7Vnodes = $data3_192.168.0.7 +print 192.168.0.7 $dnode7Vnodes + +if $dnode1Vnodes != 4 then + goto show3 +endi +if $dnode3Vnodes != 2 then + goto show3 +endi +if $dnode4Vnodes != 2 then + goto show3 +endi +if $dnode5Vnodes != 2 then + goto show3 +endi +if $dnode6Vnodes != 2 then + goto show3 +endi +if $dnode7Vnodes != 2 then + goto show3 +endi + +print ============================ step4 +print ========= add db3 +sql create database d_b5_d3 replica 5 +sql use d_b5_d3 +create3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql create table d_b5_t3 (t timestamp, i int) -x create3 +sql insert into d_b5_t3 values(now+1s, 35) +sql insert into d_b5_t3 values(now+2s, 34) +sql insert into d_b5_t3 values(now+3s, 33) +sql insert into d_b5_t3 values(now+4s, 32) +sql insert into d_b5_t3 values(now+5s, 31) + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show4 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes +$dnode7Vnodes = $data3_192.168.0.7 +print 192.168.0.7 $dnode7Vnodes + +if $dnode1Vnodes != 4 then + goto show4 +endi +if $dnode3Vnodes != 1 then + goto show4 +endi +if $dnode4Vnodes != 1 then + goto show4 +endi +if $dnode5Vnodes != 1 then + goto show4 +endi +if $dnode6Vnodes != 1 then + goto show4 +endi +if $dnode7Vnodes != 1 then + goto show4 +endi + +print ============================ step5 +print ========= start dnode8 +sql create dnode 192.168.0.8 +system sh/exec.sh -n dnode8 -s start +sleep 7000 +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show5 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode8Vnodes = $data3_192.168.0.8 +print 192.168.0.8 $dnode8Vnodes + +if $dnode1Vnodes != 4 then + goto show5 +endi +if $dnode8Vnodes != 2 then + goto show5 +endi + +print ============================ step6 +print ========= drop dnode3 +sql drop dnode 192.168.0.3 +sleep 7000 +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode4Vnodes = $data3_192.168.0.4 +print 192.168.0.4 $dnode4Vnodes +$dnode5Vnodes = $data3_192.168.0.5 +print 192.168.0.5 $dnode5Vnodes +$dnode6Vnodes = $data3_192.168.0.6 +print 192.168.0.6 $dnode6Vnodes +$dnode7Vnodes = $data3_192.168.0.7 +print 192.168.0.7 $dnode7Vnodes +$dnode8Vnodes = $data3_192.168.0.8 +print 192.168.0.8 $dnode8Vnodes + +if $dnode1Vnodes != 4 then + goto show6 +endi +if $dnode4Vnodes != 1 then + goto show6 +endi +if $dnode5Vnodes != 1 then + goto show6 +endi +if $dnode6Vnodes != 1 then + goto show6 +endi +if $dnode7Vnodes != 1 then + goto show6 +endi +if $dnode8Vnodes != 1 then + goto show6 +endi + +system sh/exec.sh -n dnode3 -s stop + +return +print ============================ step7 +print ========= check data + +sql use d_b5_d1 +sql select * from d_b5_t1 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql use d_b5_d2 +sql select * from d_b5_t2 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql use d_b5_d3 +sql select * from d_b5_t3 +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + + +print ============================================ over +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop +system sh/exec.sh -n dnode7 -s stop +system sh/exec.sh -n dnode8 -s stop diff --git a/tests/script/unique/dnode/backup/unremove.sim b/tests/script/unique/dnode/backup/unremove.sim new file mode 100644 index 0000000000..75aaeb949b --- /dev/null +++ b/tests/script/unique/dnode/backup/unremove.sim @@ -0,0 +1,149 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 1 +system sh/cfg.sh -n dnode2 -c commitLog -v 1 +system sh/cfg.sh -n dnode3 -c commitLog -v 1 +system sh/cfg.sh -n dnode4 -c commitLog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql create database d1 replica 3 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+2s, 13) +sql insert into d1.t1 values(now+3s, 12) +sql insert into d1.t1 values(now+4s, 11) + +print ========== step2 +sql drop dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql alter dnode 192.168.0.2 unremove +system sh/exec.sh -n dnode2 -s start + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 3 then + return -1 +endi +if $data3_192.168.0.2 != 3 then + return +endi +if $data3_192.168.0.3 != 3 then + return -1 +endi + +print ========== step3 +sql drop dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql alter dnode 192.168.0.2 unremove +system sh/exec.sh -n dnode2 -s start + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 3 then + return -1 +endi +if $data3_192.168.0.2 != 3 then + return -1 +endi +if $data3_192.168.0.3 != 3 then + return -1 +endi + +print ========== step4 +sql create dnode 192.168.0.4 +sql drop dnode 192.168.0.2 + +sleep 5000 +sql show dnodes +$dnode1Vnodes = $data2_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data2_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data2_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 3 then + return -1 +endi +if $data3_192.168.0.2 != 3 then + return -1 +endi +if $data3_192.168.0.3 != 3 then + return -1 +endi + +print ========== step5 +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +$x = 0 +show5: + $x = $x + 1 + sleep 5000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 3 then + goto show5 +endi +if $data3_192.168.0.2 != null then + goto show5 +endi +if $data3_192.168.0.3 != 3 then + goto show5 +endi +if $data3_192.168.0.4 != 3 then + goto show5 +endi diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/unique/dnode/balance1.sim new file mode 100644 index 0000000000..b7da8cb9ca --- /dev/null +++ b/tests/script/unique/dnode/balance1.sim @@ -0,0 +1,336 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql create database d1 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 3 then + return -1 +endi + +print ========== step2 +sleep 2000 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show2 +endi +if $data3_192.168.0.2 != 3 then + goto show2 +endi + +print ========== step3 +sql create database d2 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 2 then + return -1 +endi + +print ========== step4 +sql drop dnode 192.168.0.2 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 2 then + goto show4 +endi +if $data3_192.168.0.2 != null then + goto show4 +endi +if $rows != 1 then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + goto show5 +endi +if $data3_192.168.0.2 != null then + goto show5 +endi +if $data3_192.168.0.3 != 2 then + goto show5 +endi + +print ========== step6 +sql create database d3 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 + +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi +if $data3_192.168.0.3 != 1 then + return -1 +endi + +print ========== step7 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 4 then + goto show7 +endi +if $data3_192.168.0.2 != null then + goto show7 +endi +if $data3_192.168.0.3 != 2 then + goto show7 +endi +if $data3_192.168.0.4 != 3 then + goto show7 +endi + +print ========== step8 +sql create database d4 tables 4 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 + +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi +if $data3_192.168.0.3 != 2 then + return -1 +endi +if $data3_192.168.0.4 != 2 then + return -1 +endi + +print ========== step9 +sql drop dnode 192.168.0.3 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 + +if $data3_192.168.0.1 != 4 then + goto show9 +endi +if $data3_192.168.0.2 != null then + goto show9 +endi +if $data3_192.168.0.3 != null then + goto show9 +endi +if $data3_192.168.0.4 != 0 then + goto show9 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step10 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim new file mode 100644 index 0000000000..afe82f8cdd --- /dev/null +++ b/tests/script/unique/dnode/balance2.sim @@ -0,0 +1,285 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode5 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql create database d1 replica 2 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 2 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 2 then + return -1 +endi +if $data3_192.168.0.3 != 2 then + return -1 +endi + +print ========== step2 +sql drop dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 2 then + goto show2 +endi +if $data3_192.168.0.2 != null then + goto show2 +endi +if $data3_192.168.0.3 != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 4 then + goto show3 +endi +if $data3_192.168.0.2 != null then + goto show3 +endi +if $data3_192.168.0.3 != 2 then + goto show3 +endi +if $data3_192.168.0.4 != 2 then + goto show3 +endi + +print ========== step4 +sql create database d3 replica 2 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi +if $data3_192.168.0.3 != 1 then + return -1 +endi +if $data3_192.168.0.4 != 1 then + return -1 +endi + +print ========== step5 +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 +if $data3_192.168.0.1 != 4 then + goto show5 +endi +if $data3_192.168.0.2 != null then + goto show5 +endi +if $data3_192.168.0.3 != 2 then + goto show5 +endi +if $data3_192.168.0.4 != 2 then + goto show5 +endi +if $data3_192.168.0.5 != 2 then + goto show5 +endi + +print ========== step6 +sql drop dnode 192.168.0.3 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 +if $data3_192.168.0.1 != 4 then + goto show6 +endi +if $data3_192.168.0.2 != null then + goto show6 +endi +if $data3_192.168.0.3 != null then + goto show6 +endi +if $data3_192.168.0.4 != 1 then + goto show6 +endi +if $data3_192.168.0.5 != 1 then + goto show6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi diff --git a/tests/script/unique/dnode/balance3.sim b/tests/script/unique/dnode/balance3.sim new file mode 100644 index 0000000000..fc46736ef8 --- /dev/null +++ b/tests/script/unique/dnode/balance3.sim @@ -0,0 +1,317 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode5 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode6 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode6 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode5 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode6 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 +system sh/cfg.sh -n dnode5 -c clog -v 1 +system sh/cfg.sh -n dnode6 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +sql create database d1 replica 3 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 replica 3 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 + +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 2 then + return -1 +endi +if $data3_192.168.0.3 != 2 then + return -1 +endi +if $data3_192.168.0.4 != 2 then + return -1 +endi + +print ========== step2 +sql drop dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 + +if $data3_192.168.0.1 != 2 then + goto show2 +endi +if $data3_192.168.0.2 != null then + goto show2 +endi +if $data3_192.168.0.3 != 2 then + goto show2 +endi +if $data3_192.168.0.4 != 2 then + goto show2 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step +sql create dnode 192.168.0.5 +system sh/exec.sh -n dnode5 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 4000 + if $x == 15 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 + +if $data3_192.168.0.1 != 4 then + goto show3 +endi +if $data3_192.168.0.2 != null then + goto show3 +endi +if $data3_192.168.0.3 != 2 then + goto show3 +endi +if $data3_192.168.0.4 != 2 then + goto show3 +endi +if $data3_192.168.0.5 != 2 then + goto show3 +endi + +print ========== step4 +sql create database d3 replica 3 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 + +if $data3_192.168.0.1 != 4 then + goto show4 +endi +if $data3_192.168.0.2 != null then + goto show4 +endi +if $data3_192.168.0.3 != 1 then + goto show4 +endi +if $data3_192.168.0.4 != 1 then + goto show4 +endi +if $data3_192.168.0.5 != 1 then + goto show4 +endi + +print ========== step5 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 + +if $data3_192.168.0.1 != 4 then + goto show5 +endi +if $data3_192.168.0.2 != 2 then + goto show5 +endi + +sleep 8000 + +print ========== step6 +sql drop dnode 192.168.0.3 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +print 192.168.0.5 freeVnodes $data3_192.168.0.5 + +if $data3_192.168.0.1 != 4 then + goto show6 +endi +if $data3_192.168.0.2 != 1 then + goto show6 +endi +if $data3_192.168.0.3 != null then + goto show6 +endi +if $data3_192.168.0.4 != 1 then + goto show6 +endi +if $data3_192.168.0.5 != 1 then + goto show6 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +print ========== step7 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim new file mode 100644 index 0000000000..9e90ebf5d4 --- /dev/null +++ b/tests/script/unique/dnode/balancex.sim @@ -0,0 +1,213 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql create database d1 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show2 +endi +if $data3_192.168.0.2 != 2 then + goto show2 +endi + +print ========== step3 +sql create database d3 replica 2 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 3 then + goto show3 +endi +if $data3_192.168.0.2 != 1 then + goto show3 +endi + +print ========== step3 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show4: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + goto show4 +endi +if $data3_192.168.0.2 != 2 then + goto show4 +endi +if $data3_192.168.0.3 != 2 then + goto show4 +endi + +print ========== step5 +sql drop dnode 192.168.0.2 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 3 then + goto show5 +endi +if $data3_192.168.0.2 != null then + goto show5 +endi +if $data3_192.168.0.3 != 1 then + goto show5 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + diff --git a/tests/script/unique/dnode/monitor_bug.sim b/tests/script/unique/dnode/monitor_bug.sim new file mode 100644 index 0000000000..dd792bccbb --- /dev/null +++ b/tests/script/unique/dnode/monitor_bug.sim @@ -0,0 +1,70 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c monitor -v 1 +system sh/cfg.sh -n dnode2 -c monitor -v 0 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 5000 + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 3 then + return -1 +endi + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show2 +endi +if $data3_192.168.0.2 != 3 then + goto show2 +endi + +print ========== step3 +sleep 3000 +sql show log.tables + +print $data00 +print $data10 +print $data20 +print $data30 +print $data40 +print $data50 + +if $rows != 5 then + return -1 +endi diff --git a/tests/script/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim new file mode 100644 index 0000000000..4e05916e56 --- /dev/null +++ b/tests/script/unique/dnode/offline1.sim @@ -0,0 +1,76 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != ready then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 6000 + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != offline then + return -1 +endi + +print ========== step3 +sleep 10000 + +$x = 0 +show4: + $x = $x + 1 + sleep 5000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $data4_192.168.0.1 != ready then + goto show4 +endi +if $data4_192.168.0.2 != null then + goto show4 +endi + diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim new file mode 100644 index 0000000000..cd9ec5ee5c --- /dev/null +++ b/tests/script/unique/dnode/offline2.sim @@ -0,0 +1,104 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql create database d1 replica 2 tables 4 +sql create table d1.t1(ts timestamp, i int) +sql insert into d1.t1 values(now, 1) + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != ready then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != offline then + return -1 +endi + +print ========== step3 +sleep 18000 + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != offline then + return -1 +endi + +print ========== step4 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sql drop dnode 192.168.0.2 + +sleep 5000 +$x = 0 +show4: + $x = $x + 1 + sleep 5000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $data4_192.168.0.1 != ready then + return -1 +endi +if $data4_192.168.0.2 != null then + return -1 +endi +if $data4_192.168.0.3 != ready then + return -1 +endi + +print ======================== step5 +sleep 10000 +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/unique/dnode/remove1.sim new file mode 100644 index 0000000000..8d5a3c5ee6 --- /dev/null +++ b/tests/script/unique/dnode/remove1.sim @@ -0,0 +1,211 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql create database d1 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +sql create database d3 replica 2 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 3 then + goto show2 +endi +if $data3_192.168.0.2 != 1 then + goto show2 +endi + +print ========== step3 +sql drop dnode 192.168.0.2 + +sleep 7001 +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 $data5_192.168.0.2 + +print ========== step4 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.2 != null then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +print 192.168.0.4 freeVnodes $data3_192.168.0.4 +if $data3_192.168.0.1 != 4 then + goto show5 +endi +if $data3_192.168.0.2 != null then + goto show5 +endi +if $data3_192.168.0.3 != 2 then + goto show5 +endi +if $data3_192.168.0.4 != 2 then + goto show5 +endi + +print ========== step6 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim new file mode 100644 index 0000000000..d8727767ad --- /dev/null +++ b/tests/script/unique/dnode/remove2.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql create database d1 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql create database d2 tables 4 +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 2 then + return -1 +endi + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 9000 + +sql create database d3 replica 2 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 3 then + goto show2 +endi +if $data3_192.168.0.2 != 1 then + goto show2 +endi + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sql drop dnode 192.168.0.2 +sleep 7001 + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 $data5_192.168.0.2 + +print ========== step4 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.2 != null then + goto show4 +endi +if $data3_192.168.0.1 != 3 then + goto show4 +endi +if $data3_192.168.0.3 != 1 then + goto show4 +endi + +print ========== step5 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi diff --git a/tests/script/unique/dnode/testSuite.sim b/tests/script/unique/dnode/testSuite.sim new file mode 100644 index 0000000000..9929bfe43a --- /dev/null +++ b/tests/script/unique/dnode/testSuite.sim @@ -0,0 +1,13 @@ +run cluster/dnode/balance1.sim +run cluster/dnode/balance2.sim +run cluster/dnode/balance3.sim +run cluster/dnode/balancex.sim +run cluster/dnode/offline1.sim +run cluster/dnode/offline2.sim +run cluster/dnode/remove1.sim +run cluster/dnode/remove2.sim +run cluster/dnode/vnode_clean.sim + + + + diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim new file mode 100644 index 0000000000..300d1dd4f0 --- /dev/null +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -0,0 +1,321 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database d1 tables 4 +sql create table d1.t1 (t timestamp, i int) +sql insert into d1.t1 values(now+1s, 15) +sql insert into d1.t1 values(now+2s, 14) +sql insert into d1.t1 values(now+3s, 13) +sql insert into d1.t1 values(now+4s, 12) +sql insert into d1.t1 values(now+5s, 11) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +if $data3_192.168.0.1 != 3 then + return -1 +endi + +print ========== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show2 +endi +if $data3_192.168.0.2 != 3 then + goto show2 +endi + +print ========== step3 +sql create database d2 tables 4 + +sql create table d2.t2 (t timestamp, i int) +sql insert into d2.t2 values(now+1s, 25) +sql insert into d2.t2 values(now+2s, 24) +sql insert into d2.t2 values(now+3s, 23) +sql insert into d2.t2 values(now+4s, 22) +sql insert into d2.t2 values(now+5s, 21) + +$x = 0 +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 2 then + return -1 +endi + +print ========== step4 +sql drop dnode 192.168.0.2 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 2 then + goto show4 +endi +if $data3_192.168.0.2 != null then + goto show4 +endi +if $rows != 1 then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step5 +sleep 2000 +sql create dnode 192.168.0.2 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +show5: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show5 +endi +if $data3_192.168.0.2 != 2 then + goto show5 +endi + +print ========== step6 +sql create database d3 tables 4 +sql create table d3.t3 (t timestamp, i int) +sql insert into d3.t3 values(now+1s, 35) +sql insert into d3.t3 values(now+2s, 34) +sql insert into d3.t3 values(now+3s, 33) +sql insert into d3.t3 values(now+4s, 32) +sql insert into d3.t3 values(now+5s, 31) + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 1 then + return -1 +endi + +print ========== step7 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +show7: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + goto show7 +endi +if $data3_192.168.0.2 != 2 then + goto show7 +endi +if $data3_192.168.0.3 != 3 then + goto show7 +endi + +print ========== step8 +sql create database d4 +sql create table d4.t4 (t timestamp, i int) +sql insert into d4.t4 values(now+1s, 45) +sql insert into d4.t4 values(now+2s, 44) +sql insert into d4.t4 values(now+3s, 43) +sql insert into d4.t4 values(now+4s, 42) +sql insert into d4.t4 values(now+5s, 41) + +$x = 0 +show8: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + goto show8 +endi +if $data3_192.168.0.2 != 2 then + goto show8 +endi +if $data3_192.168.0.3 != 2 then + goto show8 +endi + +print ========== step9 +sql drop dnode 192.168.0.2 + +$x = 0 +show9: + $x = $x + 1 + sleep 2000 + if $x == 30 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 +print 192.168.0.3 freeVnodes $data3_192.168.0.3 +if $data3_192.168.0.1 != 4 then + goto show9 +endi +if $data3_192.168.0.2 != null then + goto show9 +endi +if $data3_192.168.0.3 != 0 then + goto show9 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print ========== step10 +sql select * from d1.t1 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 11 then + return -1 +endi +if $data11 != 12 then + return -1 +endi +if $data21 != 13 then + return -1 +endi +if $data31 != 14 then + return -1 +endi +if $data41 != 15 then + return -1 +endi + +sql select * from d2.t2 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 21 then + return -1 +endi +if $data11 != 22 then + return -1 +endi +if $data21 != 23 then + return -1 +endi +if $data31 != 24 then + return -1 +endi +if $data41 != 25 then + return -1 +endi + +sql select * from d3.t3 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 31 then + return -1 +endi +if $data11 != 32 then + return -1 +endi +if $data21 != 33 then + return -1 +endi +if $data31 != 34 then + return -1 +endi +if $data41 != 35 then + return -1 +endi + +sql select * from d4.t4 order by t desc +print $data01 $data11 $data21 $data31 $data41 order by t desc +if $data01 != 41 then + return -1 +endi +if $data11 != 42 then + return -1 +endi +if $data21 != 43 then + return -1 +endi +if $data31 != 44 then + return -1 +endi +if $data41 != 45 then + return -1 +endi + diff --git a/tests/script/unique/http/admin.sim b/tests/script/unique/http/admin.sim new file mode 100644 index 0000000000..b09acd614d --- /dev/null +++ b/tests/script/unique/http/admin.sim @@ -0,0 +1,180 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +#system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 +system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +print ============================ dnode1 start + +print =============== step0 - prepare data +sql create database d1 +sql use d1 + +sql create table table_admin (ts timestamp, i int) + +sql insert into table_admin values('2017-12-25 21:28:41.022', 1) +sql insert into table_admin values('2017-12-25 21:28:42.022', 2) +sql insert into table_admin values('2017-12-25 21:28:43.022', 3) +sql insert into table_admin values('2017-12-25 21:28:44.022', 4) +sql insert into table_admin values('2017-12-25 21:28:45.022', 5) +sql insert into table_admin values('2017-12-25 21:28:46.022', 6) +sql insert into table_admin values('2017-12-25 21:28:47.022', 7) +sql insert into table_admin values('2017-12-25 21:28:48.022', 8) +sql insert into table_admin values('2017-12-25 21:28:49.022', 9) +sql insert into table_admin values('2017-12-25 21:28:50.022', 10) + +print =============== step1 - login + +system_content curl 192.168.0.1:6020/admin/ +print 1-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/admin/xx +print 2-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/admin/login +print 3-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/admin/login/root +print 4-> $system_content +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/admin/login/root/123 +print 5-> $system_content +if $system_content != @{"status":"error","code":10,"desc":"authentication failure"}@ then + return -1 +endi + +system_content curl 192.168.0.1:6020/admin/login/root/123/1/1/3 +print 6-> $system_content +if $system_content != @{"status":"error","code":10,"desc":"authentication failure"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.' -d 'show databases' 192.168.0.1:6020/admin/login/root/1 +print 7-> $system_content +if $system_content != @{"status":"error","code":1010,"desc":"invalid type of Authorization"}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' 192.168.0.1:6020/admin/login/root/1 +print 8-> $system_content +if $system_content != @{"status":"error","code":1053,"desc":"parse http auth token error"}@ then + return -1 +endi + +sleep 3000 +system_content curl 127.0.0.1:6020/admin/login/root/taosdata +print 9 -----> $system_content + +if $system_content != {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"} then + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 192.168.0.1:6020/admin/login/root/1 +#print 10-> $system_content +#if $system_content != @{"status":"error","code":29,"desc":"failed to connect to server"}@ then +# return -1 +#endi + +print =============== step2 - logout + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/admin/logout +print 10 -----> $system_content + +if $system_content != @{"status":"succ","code":0,"desc":"logout success"}@ then + return -1 +endi + +system_content curl 127.0.0.1:6020/admin/logout +print 11 -----> $system_content + +if $system_content != @{"status":"error","code":1011,"desc":"no auth info input"}@ then + return -1 +endi + +print =============== step3 - info + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/admin/info +print curl 127.0.0.1:6020/admin/info -----> $system_content +if $system_content != {"status":"succ","data":[{"dbs":1,"tables":1,"users":3,"mnodes":1,"dnodes":1}]} then + return -1 +endi + +print =============== step4 - meta + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show mnodes' 127.0.0.1:6020/admin/meta +print curl 127.0.0.1:6020/admin/meta -----> $system_content +if $system_content != @{"status":"succ","head":["column type","column name","column bytes"],"data":[["binary","IP",16],["timestamp","created time",8],["binary","status",10],["binary","role",10],["binary","public ip",16]],"rows":5}@ then + return -1 +endi + +print =============== step5 - query data + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:6020/admin/sql +print curl 127.0.0.1:6020/admin/all -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:6020/admin/sql +print curl 127.0.0.1:6020/admin/sql -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}@ then + return -1 +endi + +print =============== step6 - insert data +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.table_admin values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:6020/admin/sql +print curl 127.0.0.1:6020/admin/sql -----> $system_content +if $system_content != @{"status":"succ","head":["affect_rows"],"data":[[1]],"rows":1}@ then + return -1 +endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:6020/admin/all +print curl 127.0.0.1:6020/admin/all -----> $system_content +if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:51.022",11]],"rows":11}@ then + return -1 +endi + +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' 127.0.0.1:6020/admin/sql +#print curl 127.0.0.1:6020/admin/sql -----> $system_content +#if $system_content != @{"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:51.022",11],["2017-12-25 21:28:50.022",10],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:42.022",2]],"rows":10}@ then +# return -1 +#endi + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' 127.0.0.1:6020/admin/info +print curl 127.0.0.1:6020/admin/info -----> $system_content +if $system_content != {"status":"succ","data":[{"dbs":1,"tables":1,"users":3,"mnodes":1,"dnodes":1}]} then + return -1 +endi + +print =============== step7 - use dbs + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'use d1;' 127.0.0.1:6020/admin/all +print 23-> $system_content +if $system_content != @{"status":"error","code":1017,"desc":"no need to execute use db cmd"}@ then + return -1 +endi + +print =============== step8 - monitor dbs +#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show dnodes;show mnodes;' 127.0.0.1:6020/admin/sqls +#print 24-> $system_content +#if $system_content != @[{"status":"succ","head":["IP","created time","open vnodes","free vnodes","status","balance state"],"data":[["192.168.0.1","2018-09-04 #11:16:13.985",1,3,"ready","balanced"]],"rows":1},{"status":"succ","head":["IP","created time","status","role"],"data":[["192.168.0.1","2018-09-04 11:16:13.371","serving","master"]],"rows":1}]@ then +# return -1 +# endi \ No newline at end of file diff --git a/tests/script/unique/http/testSuite.sim b/tests/script/unique/http/testSuite.sim new file mode 100644 index 0000000000..cfc86d9c9f --- /dev/null +++ b/tests/script/unique/http/testSuite.sim @@ -0,0 +1 @@ +run cluster/http/admin.sim \ No newline at end of file diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim new file mode 100644 index 0000000000..ec806d71a0 --- /dev/null +++ b/tests/script/unique/import/replica2.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +sql create database ir2db replica 2 days 7 +sql use ir2db +sql create table tb(ts timestamp, i int) + +print ================= step1 +sql import into tb values(1520000010000, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(1520000008000, 8000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step3 +sql insert into tb values(1520000020000, 20000) +sql select * from tb; +print $rows +if $rows != 2 then + return -1 +endi + +print ================= step4 +sql import into tb values(1520000009000, 9000) +sql import into tb values(1520000015000, 15000) +sql import into tb values(1520000030000, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000014000, 14000) +sql insert into tb values(1520000025000, 25000) +sql insert into tb values(1520000040000, 40000) +sql select * from tb; +if $rows != 6 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 7000) +sql import into tb values(1520000012000, 12000) +sql import into tb values(1520000023000, 23000) +sql import into tb values(1520000034000, 34000) +sql import into tb values(1520000050000, 50000) +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================== dnode restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================= step7 +sql import into tb values(1520000007001, 7001) +sql import into tb values(1520000012001, 12001) +sql import into tb values(1520000023001, 23001) +sql import into tb values(1520000034001, 34001) +sql import into tb values(1520000050001, 50001) +sql select * from tb; +if $rows != 16 then + return -1 +endi + +print ================= step8 +sql insert into tb values(1520000008002, 8002) +sql insert into tb values(1520000014002, 14002) +sql insert into tb values(1520000025002, 25002) +sql insert into tb values(1520000060000, 60000) +sql select * from tb; +if $rows != 17 then + return -1 +endi + +print ================= step9 +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 7003) +sql import into tb values(1518272000000, 34003) +sql import into tb values(1519136000000, 34003) +sql import into tb values(1519568000000, 34003) +sql import into tb values(1519654400000, 50001) +sql import into tb values(1519827200000, 50001) +sql import into tb values(1520345600000, 50001) +sql import into tb values(1520691200000, 50002) +sql import into tb values(1520864000000, 50003) +sql import into tb values(1521900800000, 50004) +sql import into tb values(1523110400000, 50001) +sql import into tb values(1521382400000, 500051) +sql select * from tb; +if $rows != 29 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 * from tb; +if $rows != 29 then + return -1 +endi + +print ================= step11 + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql select * from tb; +if $rows != 34 then + return -1 +endi + +print ================= step12 +#1520000000000 +#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +sql select * from tb; +if $rows != 43 then + return -1 +endi + +print ================= step13 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +print ================= step14 +#1520000000000 +#sql import into tb values(now-48d, 34003) +#sql import into tb values(now-38d, 50001) +#sql import into tb values(now-28d, 50001) + +sql import into tb values(1515852800001, 34003) +sql import into tb values(1516716800000, 50001) +sql import into tb values(1517580800000, 50001) + +sql select * from tb; +if $rows != 46 then + return -1 +endi + +print ================= step15 +system sh/exec.sh -n dnode2 -s start +sleep 8000 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 + +if $rows != 46 then + return -1 +endi diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim new file mode 100644 index 0000000000..4dfa26a6b2 --- /dev/null +++ b/tests/script/unique/import/replica3.sim @@ -0,0 +1,198 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 10 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 10 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 2000 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 2000 + +system sh/cfg.sh -n dnode1 -c commitlog -v 0 +system sh/cfg.sh -n dnode2 -c commitlog -v 0 +system sh/cfg.sh -n dnode3 -c commitlog -v 0 +system sh/cfg.sh -n dnode4 -c commitlog -v 0 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode4 -c secondIp -v 192.168.0.2 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 5000 +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + + +sql create database ir3db replica 3 days 7 +sql use ir3db +sql create table tb(ts timestamp, i int) + +print ================= step1 +sql import into tb values(now+10000a, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(now+8000a, 8000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step3 +sql insert into tb values(now+20000a, 20000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step4 +sql import into tb values(now+8000a, 9000) +sql import into tb values(now+15000a, 15000) +sql import into tb values(now+30000a, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(now+8000a, 8000) +sql insert into tb values(now+14000a, 14000) +sql insert into tb values(now+25000a, 25000) +sql insert into tb values(now+40000a, 40000) +sql select * from tb; +if $rows != 6 then + return -1 +endi + +print ================= step6 +sql import into tb values(now+7000a, 7000) +sql import into tb values(now+12000a, 12000) +sql import into tb values(now+23000a, 23000) +sql import into tb values(now+34000a, 34000) +sql import into tb values(now+50000a, 50000) +sql select * from tb; +if $rows != 11 then + return -1 +endi + +#print ================== dnode restart +#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#sleep 5000 +#system sh/exec.sh -n dnode1 -s start +#sleep 5000 +#sql select * from tb; +#if $rows != 11 then +# return -1 +#endi + +print ================= step7 +sql import into tb values(now+7001a, 7001) +sql import into tb values(now+12001a, 12001) +sql import into tb values(now+23001a, 23001) +sql import into tb values(now+34001a, 34001) +sql import into tb values(now+50001a, 50001) +sql select * from tb; +if $rows != 16 then + return -1 +endi + +print ================= step8 +sql insert into tb values(now+8002a, 8002) +sql insert into tb values(now+14002a, 14002) +sql insert into tb values(now+25002a, 25002) +sql insert into tb values(now+200000a, 60000) +sql select * from tb; +if $rows != 17 then + return -1 +endi + +print ================= step9 +sql import into tb values(now-30d, 7003) +sql import into tb values(now-20d, 34003) +sql import into tb values(now-10d, 34003) +sql import into tb values(now-5d, 34003) +sql import into tb values(now+1m, 50001) +sql import into tb values(now+2m, 50001) +sql import into tb values(now+6m, 50001) +sql import into tb values(now+8m, 50002) +sql import into tb values(now+10m, 50003) +sql import into tb values(now+12m, 50004) +sql import into tb values(now+14m, 50001) +sql import into tb values(now+16m, 500051) +sql select * from tb; +if $rows != 29 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 * from tb; +if $rows != 29 then + return -1 +endi + +print ================= step11 +sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql select * from tb; +if $rows != 34 then + return -1 +endi + +print ================= step12 +sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +sql select * from tb; +if $rows != 43 then + return -1 +endi + +print ================= step13 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +print ================= step14 +sql import into tb values(now-48d, 34003) +sql import into tb values(now-38d, 50001) +sql import into tb values(now-28d, 50001) +sql select * from tb; +if $rows != 46 then + return -1 +endi + +print ================= step15 +system sh/exec.sh -n dnode2 -s start +sleep 8000 +system sh/exec.sh -n dnode3 -s stop +sleep 3000 + +if $rows != 46 then + return -1 +endi diff --git a/tests/script/unique/import/testSuite.sim b/tests/script/unique/import/testSuite.sim new file mode 100644 index 0000000000..e004e8f62b --- /dev/null +++ b/tests/script/unique/import/testSuite.sim @@ -0,0 +1,2 @@ +run cluster/import/replica2.sim +run cluster/import/replica3.sim \ No newline at end of file diff --git a/tests/script/unique/metrics/balance_replica1.sim b/tests/script/unique/metrics/balance_replica1.sim new file mode 100644 index 0000000000..35c20986cb --- /dev/null +++ b/tests/script/unique/metrics/balance_replica1.sim @@ -0,0 +1,141 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 + +$dbPrefix = br1_db +$tbPrefix = br1_tb +$mtPrefix = br1_mt +$tbNum = 13 +$rowNum = 200 +$totalNum = 200 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix +$st = $stPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + while $y < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show1 +endi +if $dnode2Vnodes != null then + goto show1 +endi +print =============== step3 start dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +print select * from $tb ==> $rows +if $rows != 200 then + return -1 +endi + +print =============== step5 +sql select * from $mt +print select * from $mt ==> $rows +if $rows != 2600 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode2.sim b/tests/script/unique/metrics/dnode2.sim new file mode 100644 index 0000000000..68000fb046 --- /dev/null +++ b/tests/script/unique/metrics/dnode2.sim @@ -0,0 +1,198 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = d2_db +$tbPrefix = d2_tb +$mtPrefix = d2_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode2_stop.sim b/tests/script/unique/metrics/dnode2_stop.sim new file mode 100644 index 0000000000..2570e0789f --- /dev/null +++ b/tests/script/unique/metrics/dnode2_stop.sim @@ -0,0 +1,151 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = d2s_db +$tbPrefix = d2s_tb +$mtPrefix = d2s_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +sql show dnodes; +print dnodes ==> $rows +if $rows != 2 then + return -1 +endi + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print =============== step2 +sql select count(*) from $mt -x step2 + return -1 +step2: + +sql select count(tbcol) from $mt -x step21 + return -1 +step21: + +system sh/exec.sh -n dnode2 -s start +sleep 10000 + +print =============== step3 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode3.sim b/tests/script/unique/metrics/dnode3.sim new file mode 100644 index 0000000000..1e7dcffc24 --- /dev/null +++ b/tests/script/unique/metrics/dnode3.sim @@ -0,0 +1,227 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi + + +print ======================== dnode1 start + +$dbPrefix = d3_db +$tbPrefix = d3_tb +$mtPrefix = d3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sql show dnodes +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes +$dnode3Vnodes = $data3_192.168.0.3 +print 192.168.0.3 $dnode3Vnodes + +if $dnode1Vnodes != 3 then + return -1 +endi +if $dnode2Vnodes != 3 then + return -1 +endi +if $dnode3Vnodes != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/replica2_dnode4.sim b/tests/script/unique/metrics/replica2_dnode4.sim new file mode 100644 index 0000000000..8f2f4a9c0c --- /dev/null +++ b/tests/script/unique/metrics/replica2_dnode4.sim @@ -0,0 +1,218 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r2d4_db +$tbPrefix = r2d4_tb +$mtPrefix = r2d4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 2 tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/replica2_vnode3.sim b/tests/script/unique/metrics/replica2_vnode3.sim new file mode 100644 index 0000000000..ab808b8603 --- /dev/null +++ b/tests/script/unique/metrics/replica2_vnode3.sim @@ -0,0 +1,195 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r2v3_db +$tbPrefix = r2v3_tb +$mtPrefix = r2v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 2 tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/replica3_dnode6.sim b/tests/script/unique/metrics/replica3_dnode6.sim new file mode 100644 index 0000000000..799633b8f0 --- /dev/null +++ b/tests/script/unique/metrics/replica3_dnode6.sim @@ -0,0 +1,248 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 +system sh/cfg.sh -n dnode6 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode5 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode6 -c sessionsPerVnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +sql create dnode 192.168.0.5 +sql create dnode 192.168.0.6 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi +if $data4_192.168.0.5 == offline then + goto createDnode +endi +if $data4_192.168.0.6 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3d6_db +$tbPrefix = r3d6_tb +$mtPrefix = r3d6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +sql show dnodes; +print dnodes ==> $rows +if $rows != 6 then + return -1 +endi + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 3 tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +#sql select count(tbcol) as b from $mt interval(1m) +#print ===> $data01 +#if $data01 != 10 then +# return -1 +#endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/replica3_vnode3.sim b/tests/script/unique/metrics/replica3_vnode3.sim new file mode 100644 index 0000000000..aee839e80f --- /dev/null +++ b/tests/script/unique/metrics/replica3_vnode3.sim @@ -0,0 +1,217 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = r3v3_db +$tbPrefix = r3v3_tb +$mtPrefix = r3v3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db replica 3 tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $val = $x * 60000 + $ms = 1519833600000 + $val + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql show vgroups +print vgroups ==> $rows +if $rows != 3 then + return -1 +endi + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts <= 1519833840000 +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts <= 1519833840000 +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000 +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi +return +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/metrics/testSuite.sim b/tests/script/unique/metrics/testSuite.sim new file mode 100644 index 0000000000..6740a66489 --- /dev/null +++ b/tests/script/unique/metrics/testSuite.sim @@ -0,0 +1,4 @@ +run cluster/metrics/disk.sim +run cluster/metrics/metrics.sim +run cluster/metrics/values.sim +run cluster/metrics/vnode3.sim \ No newline at end of file diff --git a/tests/script/unique/mnode/backup/mgmt44.sim b/tests/script/unique/mnode/backup/mgmt44.sim new file mode 100644 index 0000000000..6eb70c7fb2 --- /dev/null +++ b/tests/script/unique/mnode/backup/mgmt44.sim @@ -0,0 +1,240 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 4 + +print ============================ step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + +print ============================ step2 +print ========= start dnode2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + +print ============================ step3 +print ========= start dnode3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + +print ============================ step4 +print ========= start dnode4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi + +print ============================ step5 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s start + +print ============================ step6 +print ========= create dnode2 +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi + +print ============================ step7 +print ========= stop dnode1 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != undecided then + return -1 +endi + +print ============================ step8 +print ========= drop dnode1 +sql drop dnode 192.168.0.1 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != null then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/backup/mgmt45.sim b/tests/script/unique/mnode/backup/mgmt45.sim new file mode 100644 index 0000000000..53b02847e6 --- /dev/null +++ b/tests/script/unique/mnode/backup/mgmt45.sim @@ -0,0 +1,336 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 4 +system sh/cfg.sh -n dnode5 -c numOfMPeers -v 4 + +print ============================ step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step2 +print ========= start dnode2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step3 +print ========= start dnode3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step4 +print ========= start dnode4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step5 +print ========= start dnode5 +system sh/exec.sh -n dnode5 -s start +sql create dnode 192.168.0.5 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step6 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s start + +print ============================ step7 +print ========= create dnode2 +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step8 +print ========= stop dnode1 +system sh/exec.sh -n dnode1 -s stop +sleep 14000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step9 +print ========= stop dnode1 +sql drop dnode 192.168.0.1 +sleep 8000 +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/backup/mgmt55.sim b/tests/script/unique/mnode/backup/mgmt55.sim new file mode 100644 index 0000000000..0e2b9fa2ef --- /dev/null +++ b/tests/script/unique/mnode/backup/mgmt55.sim @@ -0,0 +1,328 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 + +system sh/cfg.sh -n dnode1 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode2 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode3 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode4 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode5 -c tsNumOfMPeers -v 5 + +print ============================ step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 4000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step2 +print ========= start dnode2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step3 +print ========= start dnode3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step4 +print ========= start dnode4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step5 +print ========= start dnode5 +system sh/exec.sh -n dnode5 -s start +sql create dnode 192.168.0.5 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step6 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s start + +print ============================ step7 +print ========= create dnode2 +sql create dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step8 +print ========= stop dnode1 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step9 +print ========= stop dnode1 +sql drop dnode 192.168.0.1 +sleep 8000 +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/backup/mgmt56.sim b/tests/script/unique/mnode/backup/mgmt56.sim new file mode 100644 index 0000000000..3171ed855d --- /dev/null +++ b/tests/script/unique/mnode/backup/mgmt56.sim @@ -0,0 +1,394 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 + +system sh/cfg.sh -n dnode1 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode2 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode3 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode4 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode5 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode6 -c tsNumOfMPeers -v 5 + +print ============================ step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 4000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step2 +print ========= start dnode2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step3 +print ========= start dnode3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step4 +print ========= start dnode4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step5 +print ========= start dnode5 +system sh/exec.sh -n dnode5 -s start +sql create dnode 192.168.0.5 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + + +print ============================ step6 +print ========= start dnode6 +system sh/exec.sh -n dnode6 -s start +sql create dnode 192.168.0.6 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != null then + return -1 +endi + +print ============================ step7 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s start + +print ============================ step8 +print ========= create dnode2 +sql create dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != slave then + return -1 +endi + +print ============================ step9 +print ========= stop dnode1 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != slave then + return -1 +endi + +print ============================ step10 +print ========= stop dnode1 +sql drop dnode 192.168.0.1 +sleep 8000 +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/backup/mgmt57.sim b/tests/script/unique/mnode/backup/mgmt57.sim new file mode 100644 index 0000000000..8c6950a8df --- /dev/null +++ b/tests/script/unique/mnode/backup/mgmt57.sim @@ -0,0 +1,408 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up +system sh/ip.sh -i 6 -s up +system sh/ip.sh -i 7 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 +system sh/deploy.sh -n dnode6 -m 192.168.0.1 -i 192.168.0.6 +system sh/deploy.sh -n dnode7 -m 192.168.0.1 -i 192.168.0.7 + +system sh/cfg.sh -n dnode1 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode2 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode3 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode4 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode5 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode6 -c tsNumOfMPeers -v 5 +system sh/cfg.sh -n dnode7 -c tsNumOfMPeers -v 5 + +print ============================ step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 4000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step2 +print ========= start dnode2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step3 +print ========= start dnode3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step4 +print ========= start dnode4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != null then + return -1 +endi + +print ============================ step5 +print ========= start dnode5 +system sh/exec.sh -n dnode5 -s start +sql create dnode 192.168.0.5 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + + +print ============================ step6 +print ========= start dnode6 +system sh/exec.sh -n dnode6 -s start +sql create dnode 192.168.0.6 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != null then + return -1 +endi + + +print ============================ step7 +print ========= start dnode7 +system sh/exec.sh -n dnode7 -s start +sql create dnode 192.168.0.7 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi +if $dnode6Role != null then + return -1 +endi + +print ============================ step8 +print ========= drop dnode2 +sql drop dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s start + +print ============================ step9 +print ========= create dnode2 +sql create dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi +if $dnode5Role != slave then + return -1 +endi + +print ============================ step10 +print ========= stop dnode1 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode3Role != master then + return -1 +endi + +print ============================ step11 +print ========= stop dnode1 +sql drop dnode 192.168.0.1 +sleep 8000 +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +$dnode5Role = $data3_192.168.0.5 +$dnode6Role = $data3_192.168.0.6 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role +print 192.168.0.5 ==> $dnode5Role +print 192.168.0.6 ==> $dnode6Role + + +if $dnode1Role != null then + return -1 +endi +if $dnode3Role != master then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop +system sh/exec.sh -n dnode6 -s stop +system sh/exec.sh -n dnode7 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/drop.sim b/tests/script/unique/mnode/drop.sim new file mode 100644 index 0000000000..f96a9100f1 --- /dev/null +++ b/tests/script/unique/mnode/drop.sim @@ -0,0 +1,96 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi + +$y = 1 +step1: + +print ============== step2 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +sql drop dnode 192.168.0.2 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show4 +endi +if $data3_192.168.0.2 != null then + goto show4 +endi + +sql show dnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != 4 then + goto show4 +endi +if $data3_192.168.0.2 != null then + goto show4 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 2000 + +$y = $y + 1 +print ===> loop times: $y +if $y < 10 then + goto step1 +endi \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim new file mode 100644 index 0000000000..8d1d6c88cc --- /dev/null +++ b/tests/script/unique/mnode/mgmt22.sim @@ -0,0 +1,155 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +sql drop dnode 192.168.0.1 -x error1 + print should not drop master + return -1 +error1: + +print ============== step4 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != undecided then + goto show4 +endi +if $data3_192.168.0.2 != master then + goto show4 +endi + +print ============== step5 +sql drop dnode 192.168.0.1 +sleep 8000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != null then + goto show5 +endi +if $data3_192.168.0.2 != master then + goto show5 +endi + +print ============== step6 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.1 + +system sh/exec.sh -n dnode1 -s start +sql create dnode 192.168.0.1 +sleep 5000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != slave then + goto show6 +endi +if $data3_192.168.0.2 != master then + goto show6 +endi + +print ============== step7 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 5000 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +print 192.168.0.3 ==> $data3_192.168.0.3 +if $data3_192.168.0.1 != slave then + goto show7 +endi +if $data3_192.168.0.2 != master then + goto show7 +endi +if $data3_192.168.0.3 != null then + goto show7 +endi diff --git a/tests/script/unique/mnode/mgmt23.sim b/tests/script/unique/mnode/mgmt23.sim new file mode 100644 index 0000000000..d1a29b2cac --- /dev/null +++ b/tests/script/unique/mnode/mgmt23.sim @@ -0,0 +1,173 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step4 +sql drop dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop + +print ============== step5 +sleep 2000 +sql create dnode 192.168.0.2 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step6 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != master then + return -1 +endi + +print ============== step7 +sql drop dnode 192.168.0.1 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt24.sim b/tests/script/unique/mnode/mgmt24.sim new file mode 100644 index 0000000000..6f9476865c --- /dev/null +++ b/tests/script/unique/mnode/mgmt24.sim @@ -0,0 +1,112 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role + +if $dnode1Role != undecided then + return -1 +endi +if $dnode2Role != master then + return -1 +endi + +print ============== step4 +sql drop dnode 192.168.0.1 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != master then + return -1 +endi + + +print ============== step5 +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sql create dnode 192.168.0.1 +sql show mnodes + +$x = 0 +step5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != slave then + goto step5 +endi +if $data3_192.168.0.2 != master then + goto step5 +endi \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt25.sim b/tests/script/unique/mnode/mgmt25.sim new file mode 100644 index 0000000000..6a5e55e933 --- /dev/null +++ b/tests/script/unique/mnode/mgmt25.sim @@ -0,0 +1,96 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step4 +sql drop dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi diff --git a/tests/script/unique/mnode/mgmt26.sim b/tests/script/unique/mnode/mgmt26.sim new file mode 100644 index 0000000000..527fea5792 --- /dev/null +++ b/tests/script/unique/mnode/mgmt26.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + + +print ============== step4 +sql drop dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step5 +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +sleep 5000 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 6000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step6 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 +sql drop dnode 192.168.0.1 +sleep 12000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != master then + return -1 +endi diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim new file mode 100644 index 0000000000..f3c4d09dd3 --- /dev/null +++ b/tests/script/unique/mnode/mgmt33.sim @@ -0,0 +1,182 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.2 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +print 192.168.0.3 ==> $data3_192.168.0.3 +if $data3_192.168.0.1 != master then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi +if $data3_192.168.0.3 != null then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step4 +sql drop dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +sleep 3000 + +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +system sh/exec.sh -n dnode2 -s start + +print ============== step5 +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi + +print ============== step6 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != undecided then + return -1 +endi +#if $dnode2Role != master then +# return -1 +#endi +#if $dnode3Role != slave then +# return -1 +#endi + +print ============== step7 +sql drop dnode 192.168.0.1 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != null then + return -1 +endi +#if $dnode2Role != master then +# return -1 +#endi +#if $dnode3Role != slave then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim new file mode 100644 index 0000000000..f526f2ee72 --- /dev/null +++ b/tests/script/unique/mnode/mgmt34.sim @@ -0,0 +1,232 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +print 192.168.0.3 ==> $data3_192.168.0.3 +if $data3_192.168.0.1 != master then + return -1 +endi +if $data3_192.168.0.2 != null then + return -1 +endi +if $data3_192.168.0.3 != null then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != null then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + +print ============== step3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + + +print ============== step4 +system sh/exec.sh -n dnode4 -s start +sql create dnode 192.168.0.4 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != null then + return -1 +endi + +print ============== step5 +sql drop dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop +sleep 3000 + +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +system sh/exec.sh -n dnode2 -s start + +print ============== step6 +sql create dnode 192.168.0.2 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != slave then + return -1 +endi +if $dnode4Role != slave then + return -1 +endi + +print ============== step7 +system sh/exec.sh -n dnode1 -s stop +sleep 10000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != undecided then + return -1 +endi + +print ============== step8 +sql drop dnode 192.168.0.1 +sleep 8000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +$dnode4Role = $data3_192.168.0.4 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role +print 192.168.0.4 ==> $dnode4Role + +if $dnode1Role != null then + return -1 +endi +if $dnode2Role != slave then + return -1 +endi +#if $dnode3Role != master then +# return -1 +#endi +#if $dnode4Role != slave then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmtr1.sim b/tests/script/unique/mnode/mgmtr1.sim new file mode 100644 index 0000000000..dc1d882eee --- /dev/null +++ b/tests/script/unique/mnode/mgmtr1.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.3 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.3 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start + +sleep 1000 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start + +print ============== step3 +system sh/exec.sh -n dnode1 -s start + +$x = 0 +show3: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show3 +endi +if $data3_192.168.0.2 != slave then + goto show3 +endi + +sleep 1000 +system sh/exec.sh -n dnode1 -s stop + +print ============== step4 +print ========= start wait dnode2 is master + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.2 != master then + goto show4 +endi + +print ============== step5 +print ========= start wait dnode1 is offline + +step5: + sql show dnodes + $dnode1Status = $data4_192.168.0.1 + $dnode2Status = $data4_192.168.0.2 + $dnode3Status = $data4_192.168.0.3 + print 192.168.0.1 ==> $dnode1Status + print 192.168.0.2 ==> $dnode2Status + print 192.168.0.3 ==> $dnode3Status +if $dnode1Status != offline then + sleep 2000 + goto step5 +endi + diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim new file mode 100644 index 0000000000..e54c9f0f5b --- /dev/null +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -0,0 +1,85 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.3 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.3 +system sh/cfg.sh -n dnode3 -c secondIp -v 192.168.0.3 + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql show mnodes +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $dnode2Role != null then + return -1 +endi +if $dnode3Role != null then + return -1 +endi + +print ============== step2 +sql create dnode 192.168.0.2 +sleep 1700 +sql create dnode 192.168.0.3 + +print ============== step3 +print ========= start dnode2 and dnode3 + +system sh/exec.sh -n dnode2 -s start +sleep 1000 +system sh/exec.sh -n dnode3 -s start + +sleep 8000 +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +sleep 4000 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 4000 +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +sleep 4000 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print ============== step4 +sql show mnodes + +$dnode1Role = $data3_192.168.0.1 +$dnode2Role = $data3_192.168.0.2 +$dnode3Role = $data3_192.168.0.3 +print 192.168.0.1 ==> $dnode1Role +print 192.168.0.2 ==> $dnode2Role +print 192.168.0.3 ==> $dnode3Role + +if $dnode1Role != master then + return -1 +endi +if $rows != 2 then + return -1 +endi +if $dnode3Role != null then + return -1 +endi diff --git a/tests/script/unique/mnode/reuse.sim b/tests/script/unique/mnode/reuse.sim new file mode 100644 index 0000000000..0854795f8c --- /dev/null +++ b/tests/script/unique/mnode/reuse.sim @@ -0,0 +1,97 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.2 + +print ========== step1 dnode1 start +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ========== step2 connect to dnode1 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print ========== step3 +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 + +if $rows != 2 then + return -1 +endi +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 4 then + return -1 +endi + +print ========== step4 +system sh/exec.sh -n dnode1 -s stop +sleep 3000 + +$x = 0 +step4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.2 != master then + goto step4 +endi + +sql drop dnode 192.168.0.1 + +print ========== step5 +sleep 5000 + +$x = 0 +step5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != null then + goto step5 +endi + +print ========== step6 +sql create dnode 192.168.0.1 +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.2 + +system sh/exec.sh -n dnode1 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 2000 + if $x == 5 then + return -1 + endi + +sql show dnodes +print 192.168.0.1 ==> $data4_192.168.0.1 +print 192.168.0.2 ==> $data4_192.168.0.2 +if $data4_192.168.0.2 != ready then + goto step6 +endi + + diff --git a/tests/script/unique/mnode/secondIp.sim b/tests/script/unique/mnode/secondIp.sim new file mode 100644 index 0000000000..475eba9c4d --- /dev/null +++ b/tests/script/unique/mnode/secondIp.sim @@ -0,0 +1,35 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.2 -i 192.168.0.2 + +system sh/cfg.sh -n dnode1 -c secondIp -v 192.168.0.1 +system sh/cfg.sh -n dnode2 -c secondIp -v 192.168.0.1 + +print ========== step1 dnode2 start +system sh/exec.sh -n dnode2 -s start +sleep 3000 +sql connect + +print ========== step2 connect to dnode2 +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +print ========== step3 +sql show dnodes +print 192.168.0.1 freeVnodes $data3_192.168.0.1 +print 192.168.0.2 freeVnodes $data3_192.168.0.2 + +if $rows != 2 then + return -1 +endi +if $data3_192.168.0.1 != 4 then + return -1 +endi +if $data3_192.168.0.2 != 4 then + return -1 +endi + + + diff --git a/tests/script/unique/mnode/tcp_mgmt22.sim b/tests/script/unique/mnode/tcp_mgmt22.sim new file mode 100644 index 0000000000..02d8d15d9b --- /dev/null +++ b/tests/script/unique/mnode/tcp_mgmt22.sim @@ -0,0 +1,155 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +system sh/cfg.sh -n dnode1 -c sockettype -v tcp +system sh/cfg.sh -n dnode2 -c sockettype -v tcp +system sh/cfg.sh -n dnode3 -c sockettype -v tcp + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 3000 + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + return -1 +endi + +print ============== step2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.2 + +$x = 0 +show2: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != master then + goto show2 +endi +if $data3_192.168.0.2 != slave then + goto show2 +endi + +return + +print ============== step3 +sql drop dnode 192.168.0.1 -x error1 + print should not drop master + return -1 +error1: + +print ============== step4 +system sh/exec.sh -n dnode1 -s stop +sleep 8000 + +$x = 0 +show4: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != undecided then + goto show4 +endi +if $data3_192.168.0.2 != master then + goto show4 +endi + +print ============== step5 +sql drop dnode 192.168.0.1 +sleep 8000 + +$x = 0 +show5: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != null then + goto show5 +endi +if $data3_192.168.0.2 != master then + goto show5 +endi + +print ============== step6 +#system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +#system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/exec.sh -n dnode1 -s start +sql create dnode 192.168.0.1 +sleep 5000 + +$x = 0 +show6: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +if $data3_192.168.0.1 != slave then + goto show6 +endi +if $data3_192.168.0.2 != master then + goto show6 +endi + +print ============== step7 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.3 +sleep 5000 + +$x = 0 +show7: + $x = $x + 1 + sleep 2000 + if $x == 10 then + return -1 + endi + +sql show mnodes +print 192.168.0.1 ==> $data3_192.168.0.1 +print 192.168.0.2 ==> $data3_192.168.0.2 +print 192.168.0.3 ==> $data3_192.168.0.3 +if $data3_192.168.0.1 != slave then + goto show7 +endi +if $data3_192.168.0.2 != master then + goto show7 +endi +if $data3_192.168.0.3 != null then + goto show7 +endi diff --git a/tests/script/unique/mnode/testSuite.sim b/tests/script/unique/mnode/testSuite.sim new file mode 100644 index 0000000000..832fe33523 --- /dev/null +++ b/tests/script/unique/mnode/testSuite.sim @@ -0,0 +1,13 @@ +run cluster/mnode/mgmt22.sim +run cluster/mnode/mgmt23.sim +run cluster/mnode/mgmt24.sim +run cluster/mnode/mgmt25.sim +run cluster/mnode/mgmt26.sim +run cluster/mnode/mgmt33.sim +run cluster/mnode/mgmt34.sim +run cluster/mnode/mgmtr1.sim +run cluster/mnode/mgmtr2.sim +run cluster/mnode/drop.sim +run cluster/mnode/reuse.sim +run cluster/mnode/secondIp.sim + diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim new file mode 100644 index 0000000000..9efb32060c --- /dev/null +++ b/tests/script/unique/stream/metrics_balance.sim @@ -0,0 +1,320 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c meterMetaKeepTimer -v 5 +system sh/cfg.sh -n dnode2 -c meterMetaKeepTimer -v 5 +system sh/cfg.sh -n dnode1 -c metricMetaKeepTimer -v 5 +system sh/cfg.sh -n dnode2 -c metricMetaKeepTimer -v 5 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 3 +$rowNum = 200 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============== step1 +$db = $dbPrefix +sql create database $db tables 4 +sql use $db + +$i = 0 +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 3 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 6 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 9 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$st = $stPrefix . $i +$mt = $mtPrefix . $i +$tbNum = 12 +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + + +print =============== step2 + +sql show tables +if $rows != 16 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +$i = 0 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r0 = $rows +print $st ==> $r0 $data00 $data01 $data10 $data11 + +$i = 3 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r3 = $rows +print $st ==> $r3 $data00 $data01 $data10 $data11 + +$i = 6 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r6 = $rows +print $st ==> $r6 $data00 $data01 $data10 $data11 + +$i = 9 +$mt = $mtPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r9 = $rows +print $st ==> $r9 $data00 $data01 $data10 $data11 + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 + +$x = 0 +show1: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show1 +endi +if $dnode2Vnodes != null then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 +print =============== step5 +print sleep 22 seconds +sleep 22000 + +print =============== step6 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 9 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 +print =============== step7 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r0 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r0 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r3 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r3 then + return -1 +endi + + +$i = 6 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r6 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r6 then + return -1 +endi + +$i = 9 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r0 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r9 then + return -1 +endi + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/metrics_replica1_dnode2.sim b/tests/script/unique/stream/metrics_replica1_dnode2.sim new file mode 100644 index 0000000000..e55ffbefd7 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica1_dnode2.sim @@ -0,0 +1,262 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = m1d_db +$tbPrefix = m1d_tb +$mtPrefix = m1d_mt +$stPrefix = m1d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 32000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode2.sim b/tests/script/unique/stream/metrics_replica2_dnode2.sim new file mode 100644 index 0000000000..a3bcd45048 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode2.sim @@ -0,0 +1,260 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + + +print ======================== dnode1 start + +$dbPrefix = m2d_db +$tbPrefix = m2d_tb +$mtPrefix = m2d_mt +$stPrefix = m2d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim b/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim new file mode 100644 index 0000000000..3731df7f27 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode2_vnoden.sim @@ -0,0 +1,263 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2dv_db +$tbPrefix = m2dv_tb +$mtPrefix = m2dv_mt +$stPrefix = m2dv_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica2_dnode3.sim b/tests/script/unique/stream/metrics_replica2_dnode3.sim new file mode 100644 index 0000000000..092232b061 --- /dev/null +++ b/tests/script/unique/stream/metrics_replica2_dnode3.sim @@ -0,0 +1,273 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2d3_db +$tbPrefix = m2d3_tb +$mtPrefix = m2d3_mt +$stPrefix = m2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_replica3_dnode4.sim b/tests/script/unique/stream/metrics_replica3_dnode4.sim new file mode 100644 index 0000000000..900e26f8da --- /dev/null +++ b/tests/script/unique/stream/metrics_replica3_dnode4.sim @@ -0,0 +1,284 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start + +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = m2d3_db +$tbPrefix = m2d3_tb +$mtPrefix = m2d3_mt +$stPrefix = m2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $mt interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $mt interval(1d) +print select count(tbcol2) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $mt interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $mt interval(1d) +print select avg(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $mt interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $mt interval(1d) +print select sum(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $mt interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $mt interval(1d) +print select min(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $mt interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $mt interval(1d) +print select max(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $mt interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $mt interval(1d) +print select first(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $mt interval(1d) + +print =============== step10 la +sql select last(tbcol) from $mt interval(1d) +print select last(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $mt interval(1d) + +print =============== step11 wh +sql select count(tbcol) from $mt where ts < now + 4m interval(1d) +print select count(tbcol) from $mt where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $mt where ts < now + 4m interval(1d) + +print =============== step12 as +sql select count(tbcol) from $mt interval(1d) +print select count(tbcol) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $mt interval(1d) + +print =============== step13 +print sleep 22 seconds +sleep 22000 + +print =============== step14 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 1900 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != 200 then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi diff --git a/tests/script/unique/stream/metrics_vnode_stop.sim b/tests/script/unique/stream/metrics_vnode_stop.sim new file mode 100644 index 0000000000..47eff851d7 --- /dev/null +++ b/tests/script/unique/stream/metrics_vnode_stop.sim @@ -0,0 +1,188 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step3 +system sh/exec.sh -n dnode2 -s stop + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +print ============= step6 + +sql close +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.2 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/exec.sh -n dnode2 -s start +sleep 2000 + +$x = 0 +connectTbase2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase2 +sleep 3000 + +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step7 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step8 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $mt interval(1d) +print select count(*) from $mt interval(1d) ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $mt interval(1d) + +print =============== step9 +system sh/exec.sh -n dnode1 -s stop + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 200 then + return -1 +endi + + + diff --git a/tests/script/unique/stream/table_balance.sim b/tests/script/unique/stream/table_balance.sim new file mode 100644 index 0000000000..4b77f25189 --- /dev/null +++ b/tests/script/unique/stream/table_balance.sim @@ -0,0 +1,244 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 + +$dbPrefix = tb_db +$tbPrefix = tb_tb +$mtPrefix = tb_mt +$stPrefix = tb_st +$tbNum = 10 +$rowNum = 200 +$totalNum = 200 + +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect + +print ============== step1 +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix +$st = $stPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + if $i == 0 then + sleep 2000 + endi + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r1 = $rows +print $st ==> $r1 $data00 $data01 $data10 $data11 + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r5 = $rows +print $st ==> $r5 $data00 $data01 $data10 $data11 + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +$r8 = $rows +print $st ==> $r8 $data00 $data01 $data10 $data11 + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 + +$x = 0 +show1: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 0 then + goto show1 +endi +if $dnode2Vnodes != null then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 2 then + goto show2 +endi +if $dnode2Vnodes != 2 then + goto show2 +endi + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 +print =============== step5 +print sleep 22 seconds +sleep 22000 + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +print rows1=>$r1 rows5=>$r5 rows8=>$r8 +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r1 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r1 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r5 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r5 then + return -1 +endi + + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $r8 $rows , $data00 $data01 $data10 $data11 +if $rows == 0 then + return -1 +endi +if $rows <= $r8 then + return -1 +endi + + +if $r1 != $r5 then + return -1 +endi + +if $r8 != $r5 then + return -1 +endi + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/table_move.sim b/tests/script/unique/stream/table_move.sim new file mode 100644 index 0000000000..3a4c1c976f --- /dev/null +++ b/tests/script/unique/stream/table_move.sim @@ -0,0 +1,279 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 8 + +system sh/cfg.sh -n dnode1 -c statusInterval -v 1 +system sh/cfg.sh -n dnode2 -c statusInterval -v 1 +system sh/cfg.sh -n dnode3 -c statusInterval -v 1 +system sh/cfg.sh -n dnode4 -c statusInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode2 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode3 -c balanceMonitorInterval -v 1 +system sh/cfg.sh -n dnode4 -c balanceMonitorInterval -v 1 + +system sh/cfg.sh -n dnode1 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceStartInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceStartInterval -v 10 + +system sh/cfg.sh -n dnode1 -c clog -v 1 +system sh/cfg.sh -n dnode2 -c clog -v 1 +system sh/cfg.sh -n dnode3 -c clog -v 1 +system sh/cfg.sh -n dnode4 -c clog -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 0 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 0 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 + +system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 1000 +system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 1000 +system sh/cfg.sh -n dnode1 -c maxShellConns -v 1000 +system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 1000 + +system sh/cfg.sh -n dnode2 -c maxVnodeConnections -v 1000 +system sh/cfg.sh -n dnode2 -c maxMeterConnections -v 1000 +system sh/cfg.sh -n dnode2 -c maxShellConns -v 1000 +system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 1000 + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 5 +$rowNum = 20 +$totalNum = 200 + +print ============== step1 +print ========= start dnode1 +system sh/exec.sh -n dnode1 -s start + +sql connect +sleep 3000 + +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db tables 4 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -20 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now $ms , $x , $x ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) ===> $data00 $data01 $data02, $data03 +if $data01 != $rowNum then + return -1 +endi +if $data02 != $rowNum then + return -1 +endi +if $data03 != $rowNum then + return -1 +endi + +sql show tables +if $rows != 5 then + return -1 +endi + +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(10s) + +sql show tables +if $rows != 6 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + +sql select * from $tb +if $rows != 20 then + return -1 +endi + +sql select * from $mt +if $rows != 100 then + return -1 +endi + +sql select * from $st +print select * from $st => $data01 +if $rows == 0 then + return -1 +endi + +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show1 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 6 then + goto show1 +endi +if $dnode2Vnodes != null then + goto show1 +endi + +print =============== step4 start dnode2 +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 8000 + +$x = 0 +show2: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show2 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != 7 then + goto show2 +endi +if $dnode2Vnodes != 7 then + goto show2 +endi + +print =============== step5 drop dnode1 +system sh/exec.sh -n dnode1 -s stop +print stop dnode1 and sleep 10000 +sleep 10000 + +sql drop dnode 192.168.0.1 +print drop dnode1 and sleep 9000 +sleep 9000 + +$x = 0 +show6: + $x = $x + 1 + sleep 3000 + if $x == 20 then + return -1 + endi +sql show dnodes -x show6 +$dnode1Vnodes = $data3_192.168.0.1 +print 192.168.0.1 $dnode1Vnodes +$dnode2Vnodes = $data3_192.168.0.2 +print 192.168.0.2 $dnode2Vnodes + +if $dnode1Vnodes != null then + goto show6 +endi +if $dnode2Vnodes != 6 then + goto show6 +endi + +print =============== step6 + +print select * from $tb +sql select * from $tb +if $rows != 20 then + return -1 +endi + +print select * from $mt +sql select * from $mt +if $rows != 80 then + return -1 +endi + + +print =============== step7 +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + $y = 0 + while $y < $rowNum + $ms = $x . s + sql insert into $tb values (now + $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +$i = 0 +$tb = $tbPrefix . $i +$st = $stPrefix . $i + +print =============== step8 +print sleep 22 seconds +sleep 22000 + +print select * from $st +sql select * from $st +if $rows == 0 then + return -1 +endi + + +print =============== clear +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop + diff --git a/tests/script/unique/stream/table_replica1_dnode2.sim b/tests/script/unique/stream/table_replica1_dnode2.sim new file mode 100644 index 0000000000..5165732535 --- /dev/null +++ b/tests/script/unique/stream/table_replica1_dnode2.sim @@ -0,0 +1,141 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t1d_db +$tbPrefix = t1d_tb +$mtPrefix = t1d_mt +$stPrefix = t1d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 + +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) +print select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) --> $data00 $data01 $data02 $data03 +sql create table $st as select count(*), count(tbcol), count(tbcol2) from $tb interval(1d) + +sql show tables +if $rows != 13 then + return -1 +endi + +print =============== step3 +print sleep 22 seconds +sleep 22000 + + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 $data10 $data11 +$rows1 = $rows +if $data01 != 20 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st => $rows $data00 $data01 $data10 $data11 +$rows5 = $rows +if $data01 != 20 then + return -1 +endi + +$i = 8 +$tb = $tbPrefix . $i +$st = $stPrefix . $i +sql select * from $st +print $st ==> $rows $data00 $data01 $data10 $data11 +$rows8 = $rows +if $data01 != 20 then + return -1 +endi + +if $rows8 != $rows5 then + return -1 +endi + +if $rows8 != $rows1 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/stream/table_replica2_dnode2.sim b/tests/script/unique/stream/table_replica2_dnode2.sim new file mode 100644 index 0000000000..177d2ec344 --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode2.sim @@ -0,0 +1,312 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t2d_db +$tbPrefix = t2d_tb +$mtPrefix = t2d_mt +$stPrefix = t2d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim b/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim new file mode 100644 index 0000000000..ace39d0604 --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode2_vnoden.sim @@ -0,0 +1,316 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +print ======================== dnode1 start + +$dbPrefix = t2dv_db +$tbPrefix = t2dv_tb +$mtPrefix = t2dv_mt +$stPrefix = t2dv_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica2_dnode3.sim b/tests/script/unique/stream/table_replica2_dnode3.sim new file mode 100644 index 0000000000..658a3dd00c --- /dev/null +++ b/tests/script/unique/stream/table_replica2_dnode3.sim @@ -0,0 +1,328 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = t2d3_db +$tbPrefix = t2d3_tb +$mtPrefix = t2d3_mt +$stPrefix = t2d3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_replica3_dnode4.sim b/tests/script/unique/stream/table_replica3_dnode4.sim new file mode 100644 index 0000000000..60cab2574e --- /dev/null +++ b/tests/script/unique/stream/table_replica3_dnode4.sim @@ -0,0 +1,337 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 8 +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode4 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi +if $data4_192.168.0.3 == offline then + goto createDnode +endi +if $data4_192.168.0.4 == offline then + goto createDnode +endi + +print ======================== dnode1 start + +$dbPrefix = t3d_db +$tbPrefix = t3d_tb +$mtPrefix = t3d_mt +$stPrefix = t3d_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db replica 3 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 c2 +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql create table $st as select count(tbcol) from $tb interval(1d) + +print =============== step4 c3 +sql select count(tbcol2) from $tb interval(1d) +print select count(tbcol2) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql create table $st as select count(tbcol2) from $tb interval(1d) + +print =============== step5 avg +sql select avg(tbcol) from $tb interval(1d) +print select avg(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . av +sql create table $st as select avg(tbcol) from $tb interval(1d) + +print =============== step6 su +sql select sum(tbcol) from $tb interval(1d) +print select sum(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . su +sql create table $st as select sum(tbcol) from $tb interval(1d) + +print =============== step7 mi +sql select min(tbcol) from $tb interval(1d) +print select min(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . mi +sql create table $st as select min(tbcol) from $tb interval(1d) + +print =============== step8 ma +sql select max(tbcol) from $tb interval(1d) +print select max(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . ma +sql create table $st as select max(tbcol) from $tb interval(1d) + +print =============== step9 fi +sql select first(tbcol) from $tb interval(1d) +print select first(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . fi +sql create table $st as select first(tbcol) from $tb interval(1d) + +print =============== step10 la +sql select last(tbcol) from $tb interval(1d) +print select last(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . la +sql create table $st as select last(tbcol) from $tb interval(1d) + +print =============== step11 st +sql select stddev(tbcol) from $tb interval(1d) +print select stddev(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . std +sql create table $st as select stddev(tbcol) from $tb interval(1d) + +print =============== step12 le +sql select leastsquares(tbcol, 1, 1) from $tb interval(1d) +print select leastsquares(tbcol, 1, 1) from $tb interval(1d) ===> $data00 $data01 +#if $data01 != @(0.000017, -25362055.126740)@ then +# return -1 +#endi + +$st = $stPrefix . le +sql create table $st as select leastsquares(tbcol, 1, 1) from $tb interval(1d) + +print =============== step13 pe + +sql select percentile(tbcol, 1) from $tb interval(1d) +print select percentile(tbcol, 1) from $tb interval(1d) ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . pe +sql create table $st as select percentile(tbcol, 1) from $tb interval(1d) + +print =============== step14 wh +sql select count(tbcol) from $tb where ts < now + 4m interval(1d) +print select count(tbcol) from $tb where ts < now + 4m interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . wh +#sql create table $st as select count(tbcol) from $tb where ts < now + 4m interval(1d) + +print =============== step15 as +sql select count(tbcol) from $tb interval(1d) +print select count(tbcol) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . as +sql create table $st as select count(tbcol) as c from $tb interval(1d) + +print =============== step16 +print sleep 22 seconds +sleep 22000 + +print =============== step17 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c2 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c3 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . av +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 9.500000000 then + return -1 +endi + +$st = $stPrefix . su +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 190 then + return -1 +endi + +$st = $stPrefix . mi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . ma +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . fi +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0 then + return -1 +endi + +$st = $stPrefix . la +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 19 then + return -1 +endi + +$st = $stPrefix . std +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 5.766281297 then + return -1 +endi + +$st = $stPrefix . le +sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != @(0.000017, -25270086.331047)@ then +# return -1 +#endi + +$st = $stPrefix . pe +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != 0.190000000 then + return -1 +endi + +$st = $stPrefix . wh +#sql select * from $st +#print ===> select * from $st ===> $data00 $data01 +#if $data01 != $rowNum then +# return -1 +#endi + +$st = $stPrefix . as +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi diff --git a/tests/script/unique/stream/table_vnode_stop.sim b/tests/script/unique/stream/table_vnode_stop.sim new file mode 100644 index 0000000000..c4548dda59 --- /dev/null +++ b/tests/script/unique/stream/table_vnode_stop.sim @@ -0,0 +1,189 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/exec.sh -n dnode1 -s start + +sql connect + +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +$x = 0 +createDnode: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql show dnodes; +if $data4_192.168.0.2 == offline then + goto createDnode +endi + +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step3 +system sh/exec.sh -n dnode2 -s stop + +print =============== step4 +print sleep 22 seconds +sleep 22000 + +print =============== step5 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +print ============= step6 + +sql close +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/deploy.sh -n dnode1 -m 192.168.0.2 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.2 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +sleep 2000 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +connectTbase2: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase2 +sleep 3000 + +sql create dnode 192.168.0.1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +print ======================== dnode start + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt +$stPrefix = st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step7 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql create database $db replica 2 +sql use $db +sql create table $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = -1440 + $y = 0 + while $y < $rowNum + $ms = $x . m + sql insert into $tb values (now $ms , $y , $y ) + $x = $x + 1 + $y = $y + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step8 c1 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(*) from $tb interval(1d) +print select count(*) from $tb interval(1d) ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + +$st = $stPrefix . c1 +sql create table $st as select count(*) from $tb interval(1d) + +print =============== step9 +system sh/exec.sh -n dnode1 -s stop + +print =============== step10 +print sleep 22 seconds +sleep 22000 + +print =============== step11 +$st = $stPrefix . c1 +sql select * from $st +print ===> select * from $st ===> $data00 $data01 +if $data01 != $rowNum then + return -1 +endi + + + diff --git a/tests/script/unique/stream/testSuite.sim b/tests/script/unique/stream/testSuite.sim new file mode 100644 index 0000000000..fdf7b540de --- /dev/null +++ b/tests/script/unique/stream/testSuite.sim @@ -0,0 +1,15 @@ +run cluster/stream/table_replica1_dnode2.sim +run cluster/stream/metrics_replica1_dnode2.sim +run cluster/stream/table_replica2_dnode2.sim +run cluster/stream/metrics_replica2_dnode2.sim +run cluster/stream/table_replica2_dnode2_vnoden.sim +run cluster/stream/metrics_replica2_dnode2_vnoden.sim +run cluster/stream/table_replica2_dnode3.sim +run cluster/stream/metrics_replica2_dnode3.sim +run cluster/stream/table_replica3_dnode4.sim +run cluster/stream/metrics_replica3_dnode4.sim +run cluster/stream/table_vnode_stop.sim +run cluster/stream/metrics_vnode_stop.sim +#run cluster/stream/table_balance.sim +#run cluster/stream/metrics_balance.sim +#run cluster/stream/table_move.sim \ No newline at end of file diff --git a/tests/script/unique/table/back_insert.sim b/tests/script/unique/table/back_insert.sim new file mode 100644 index 0000000000..43831cca95 --- /dev/null +++ b/tests/script/unique/table/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/table/delete_part.sim b/tests/script/unique/table/delete_part.sim new file mode 100644 index 0000000000..dae57366d0 --- /dev/null +++ b/tests/script/unique/table/delete_part.sim @@ -0,0 +1,82 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode2 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode3 -c sessionsPerVnode -v 4 +system sh/cfg.sh -n dnode4 -c sessionsPerVnode -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +sql create database dpdb +sql use dpdb + +$loop = 0 +begin: + + print ======== step1 + + $x = 0 + while $x < 16 + $tb = tb . $x + sql create table $tb (ts timestamp, i int) + sql insert into $tb values(now, $x ) + $x = $x + 1 + endw + + print ======== step2 + system sh/exec.sh -n dnode2 -s stop + $x = 0 + while $x < 16 + $tb = tb . $x + sql drop table $tb + $x = $x + 1 + endw + + print ======== step3 + sleep 2000 + system sh/exec.sh -n dnode2 -s start + sleep 3000 + + print ===> test times : $loop + if $loop > 20 then + return 0 + endi + + $loop = $loop + 1 + +goto begin + \ No newline at end of file diff --git a/tests/script/unique/table/testSuite.sim b/tests/script/unique/table/testSuite.sim new file mode 100644 index 0000000000..e1ab34edbe --- /dev/null +++ b/tests/script/unique/table/testSuite.sim @@ -0,0 +1 @@ +run cluster/table/delete_part.sim diff --git a/tests/script/unique/vnode/back_insert.sim b/tests/script/unique/vnode/back_insert.sim new file mode 100644 index 0000000000..43831cca95 --- /dev/null +++ b/tests/script/unique/vnode/back_insert.sim @@ -0,0 +1,7 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/vnode/back_insert_many.sim b/tests/script/unique/vnode/back_insert_many.sim new file mode 100644 index 0000000000..6181a835ed --- /dev/null +++ b/tests/script/unique/vnode/back_insert_many.sim @@ -0,0 +1,10 @@ +sql connect +$x = 1 +begin: + sql insert into db1.tb1 values(now, $x ) -x begin + sql insert into db2.tb2 values(now, $x ) -x begin + sql insert into db3.tb3 values(now, $x ) -x begin + sql insert into db4.tb4 values(now, $x ) -x begin + #print ===> insert successed $x + $x = $x + 1 +goto begin \ No newline at end of file diff --git a/tests/script/unique/vnode/backup/replica4.sim b/tests/script/unique/vnode/backup/replica4.sim new file mode 100644 index 0000000000..c6eeeca58f --- /dev/null +++ b/tests/script/unique/vnode/backup/replica4.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/exec.sh -n dnode1 -s start +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 3001 + +$N = 10 +$table = table_r4 +$db = db1 + +print =================== step 1 + +$x = 0 +created: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database $db replica 4 -x created +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $table (ts timestamp, speed int) -x create1 +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 7 +system sh/exec.sh -n dnode4 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode4 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 9 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 8 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 10 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 9 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop + diff --git a/tests/script/unique/vnode/backup/replica5.sim b/tests/script/unique/vnode/backup/replica5.sim new file mode 100644 index 0000000000..3a4f28bdc2 --- /dev/null +++ b/tests/script/unique/vnode/backup/replica5.sim @@ -0,0 +1,263 @@ +system sh/stop_dnodes.sh + +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/ip.sh -i 5 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/deploy.sh -n dnode5 -m 192.168.0.1 -i 192.168.0.5 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode5 -c commitLog -v 0 + +system sh/exec.sh -n dnode1 -s start + +$x = 0 +connectTbase: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql connect -x connectTbase + +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +sql create dnode 192.168.0.5 + +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 3001 + +$N = 10 +$table = table_r5 +$db = db1 + +print =================== step 1 + +$x = 0 +created: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create database $db replica 5 -x created +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $table (ts timestamp, speed int) -x create1 + +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 7 +system sh/exec.sh -n dnode4 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode4 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + + +print =================== step 9 +system sh/exec.sh -n dnode5 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 8 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 10 +system sh/exec.sh -n dnode5 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 9 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 11 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 10 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 12 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 11 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop +system sh/exec.sh -n dnode5 -s stop + diff --git a/tests/script/unique/vnode/commit.sim b/tests/script/unique/vnode/commit.sim new file mode 100644 index 0000000000..572f4e08ec --- /dev/null +++ b/tests/script/unique/vnode/commit.sim @@ -0,0 +1,152 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +print =================== step 1 create db +sql create database c2db replica 2 days 10 keep 50 +sql use c2db +sql create table tb (ts timestamp, speed int) +sql insert into tb values(now, 0) + +print =================== step2 sleep 2000 and kill dnode2(SIGINT) +sleep 2000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 1000 + +print =================== step3 insert into dnode1 + +$x = 1 +while $x < 100 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 240 +while $x < 400 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 480 +while $x < 700 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 720 +while $x < 809 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 960 +while $x < 1043 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 1200 +while $x < 1244 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 1440 +while $x < 1677 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +$x = 1680 +while $x < 1683 + $time = $x . m + sql insert into tb values (now + $time , $x ) + $x = $x + 1 +endw + +print =================== step4 +sql select count(*) from tb +print select count(*) from tb ==> $data00 (expect 936) +if $data00 != 936 then + return -1 +endi +sql select * from tb order by ts desc +print select * from tb ==> $data00 $data01 $rows +if $data01 != 1682 then + return -1 +endi +if $rows != 936 then + return -1 +endi + +print =================== step5 sleep kill dnode1(SIGINT) then start dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec.sh -n dnode1 -s start + +sleep 3000 +print =================== step6 start dnode2 and sleep 10000 (wait sync complete) +system sh/exec.sh -n dnode2 -s start +sleep 12000 + +print =================== step7 +sql_error insert into tb values(now + 1000h, 100) +sql select count(*) from tb order by ts desc +print select count(*) from tb ==> $data00 (expect <= 936) +if $data00 != 936 then + return -1 +endi +$remainRows = $data00 + +sql select * from tb order by ts desc +print select * from tb ==> $data00 $data01 $data10 $data11 $rows + +if $data11 != 1681 then + return -1 +endi +if $rows != $remainRows then + return -1 +endi + +print =================== step8 kill dnode1(SIGINT) and query +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 2000 + +print =================== step9 +sql select count(*) from tb order by ts desc +print select count(*) from tb ==> $data00 (expect == $remainRows ) +if $data00 > $remainRows then + return -1 +endi +if $data00 <= 0 then + return -1 +endi + +$remainRows = $data00 +sql select * from tb order by ts desc +print select * from tb ==> $data00 $data01 $rows + +if $rows != $remainRows then + return -1 +endi + +system sh/exec.sh -n dnode1 -s start diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim new file mode 100644 index 0000000000..b5b87fc108 --- /dev/null +++ b/tests/script/unique/vnode/many.sim @@ -0,0 +1,119 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ========= step1 +sql create database db1 replica 2 +sql create database db2 replica 2 +sql create database db3 replica 2 +sql create database db4 replica 2 +sql create table db1.tb1 (ts timestamp, i int) +sql create table db2.tb2 (ts timestamp, i int) +sql create table db3.tb3 (ts timestamp, i int) +sql create table db4.tb4 (ts timestamp, i int) +sql insert into db1.tb1 values(now, 1) +sql insert into db2.tb2 values(now, 1) +sql insert into db3.tb3 values(now, 1) +sql insert into db4.tb4 values(now, 1) + +sql select count(*) from db1.tb1 +$lastRows1 = $rows +sql select count(*) from db2.tb2 +$lastRows2 = $rows +sql select count(*) from db3.tb3 +$lastRows3 = $rows +sql select count(*) from db4.tb4 +$lastRows4 = $rows + +print ======== step2 +run_back cluster/vnode/back_insert_many.sim +sleep 5000 + +print ======== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 10000 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s start +sleep 10000 +system sh/exec.sh -n dnode3 -s stop +sleep 10000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s start +sleep 10000 +system sh/exec.sh -n dnode2 -s stop +sleep 10000 + +print ======== step6 +sql select count(*) from db1.tb1 +print select count(*) from db1.tb1 ==> $data00 $lastRows1 +if $data00 <= $lastRows1 then + return -1 +endi +$lastRows1 = $data00 + +sql select count(*) from db2.tb2 +print select count(*) from db2.tb2 ==> $data00 $lastRows2 +if $data00 <= $lastRows2 then + return -1 +endi +$lastRows2 = $data00 + +sql select count(*) from db3.tb3 +print select count(*) from db3.tb3 ==> $data00 $lastRows3 +if $data00 <= $lastRows3 then + return -1 +endi +$lastRows3 = $data00 + +sql select count(*) from db4.tb4 +print select count(*) from db4.tb4 ==> $data00 $lastRows4 +if $data00 <= $lastRows4 then + return -1 +endi +$lastRows4 = $data00 + +print ======== step7 + +print ======== loop Times $x + +if $x < 5 then + $x = $x + 1 + goto loop +endi + + diff --git a/tests/script/unique/vnode/replica2_basic.sim b/tests/script/unique/vnode/replica2_basic.sim new file mode 100644 index 0000000000..647d692e8e --- /dev/null +++ b/tests/script/unique/vnode/replica2_basic.sim @@ -0,0 +1,193 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 + +$N = 10 +$db = d1 +$table = table_r2 + +print =================== step 1 +sql create database $db replica 3 +sql use $db +sql create table $table (ts timestamp, speed int) -x error_create +return -1 +error_create: +sql drop database $db + +print =================== step 2 + +sql create database $db replica 2 +sql use $db + +sql create table $table (ts timestamp, speed int) +sleep 1000 + +print =================== step 3 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 7 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 8 +system sh/ip.sh -i 1 -s down +system sh/ip.sh -i 2 -s up +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 9 +system sh/ip.sh -i 2 -s up +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 10 +system sh/ip.sh -i 2 -s down +system sh/ip.sh -i 1 -s up +sleep 2000 +$y = $x + $N +$expect = $N * 8 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 11 +system sh/ip.sh -i 2 -s up +sleep 2000 +$y = $x + $N +$expect = $N * 9 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 12 +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim new file mode 100644 index 0000000000..9eb6b4a6ac --- /dev/null +++ b/tests/script/unique/vnode/replica2_basic2.sim @@ -0,0 +1,215 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up + +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 + +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 + +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 + +print ========= start dnodes +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +system sh/exec.sh -n dnode2 -s start +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql reset query cache + +print ========= step1 +sql create database d1 replica 2 +sql create database d2 replica 2 +sql create database d3 replica 2 +sql create database d4 replica 2 + +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d3.t3 values(now, 1) +sql insert into d4.t4 values(now, 1) + +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 1 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 1 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 1 then + return -1 +endi + +sql show dnodes +print dnode192.168.0.1 ==> openVnodes: $data2_192.168.0.1 freeVnodes: $data3_192.168.0.1 +print dnode192.168.0.2 ==> openVnodes: $data2_192.168.0.2 freeVnodes: $data3_192.168.0.2 +print dnode192.168.0.3 ==> openVnodes: $data2_192.168.0.3 freeVnodes: $data3_192.168.0.3 + +if $data2_192.168.0.1 != 0 then + return -1 +endi + +if $data3_192.168.0.1 != 4 then + return -1 +endi + +if $data3_192.168.0.2 != 0 then + return -1 +endi + +if $data3_192.168.0.3 != 0 then + return -1 +endi + +print ========= step2 +sql insert into d1.t1 values(now, 2) +sql insert into d2.t2 values(now, 2) +sql insert into d3.t3 values(now, 2) +sql insert into d4.t4 values(now, 2) + +sql select * from d1.t1 +if $rows != 2 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 2 then + return -1 +endi + +print ========= step3 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 3) +sql insert into d2.t2 values(now, 3) +sql insert into d3.t3 values(now, 3) +sql insert into d4.t4 values(now, 3) + +sql select * from d1.t1 +if $rows != 3 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 3 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 3 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 3 then + return -1 +endi + +print ========= step4 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 4) +sql insert into d2.t2 values(now, 4) +sql insert into d3.t3 values(now, 4) +sql insert into d4.t4 values(now, 4) + +sql select * from d1.t1 +if $rows != 4 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 4 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 4 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 4 then + return -1 +endi + +print ========= step5 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 3000 + +sql insert into d1.t1 values(now, 5) +sql insert into d2.t2 values(now, 5) +sql insert into d3.t3 values(now, 5) +sql insert into d4.t4 values(now, 5) + +sql select * from d1.t1 +if $rows != 5 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 5 then + return -1 +endi + +sql select * from d3.t3 +if $rows != 5 then + return -1 +endi + +sql select * from d4.t4 +if $rows != 5 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim new file mode 100644 index 0000000000..9d7caacb59 --- /dev/null +++ b/tests/script/unique/vnode/replica2_repeat.sim @@ -0,0 +1,77 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +print ========= step1 +sql create database db replica 2 +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) +sql select count(*) from db.tb +$lastRows = $rows + +print ======== step2 +run_back cluster/vnode/back_insert.sim +sleep 3000 + +print ======== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop +sleep 5000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +print ======== step6 +sql select count(*) from db.tb +print select count(*) from db.tb ==> $data00 $lastRows +if $data00 <= $lastRows then + return -1 +endi + +print ======== step7 +$lastRows = $data00 +print ======== loop Times $x + +if $x < 5 then + $x = $x + 1 + goto loop +endi + + diff --git a/tests/script/unique/vnode/replica3_basic.sim b/tests/script/unique/vnode/replica3_basic.sim new file mode 100644 index 0000000000..b401e5fc4b --- /dev/null +++ b/tests/script/unique/vnode/replica3_basic.sim @@ -0,0 +1,158 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +$N = 10 +$table = table_r3 +$db = db1 + +sleep 3000 + +print =================== step 1 + +sql create database $db replica 3 +sql use $db +sql create table $table (ts timestamp, speed int) +sleep 3001 + +print =================== step 2 +$x = 1 +$y = $x + $N +$expect = $N +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 3 +system sh/exec.sh -n dnode2 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 4 +system sh/exec.sh -n dnode2 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 3 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 5 +system sh/exec.sh -n dnode3 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 4 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +print =================== step 6 +system sh/exec.sh -n dnode3 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 5 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , $x ) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 7 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 +$y = $x + $N +$expect = $N * 6 +while $x < $y +$ms = $x . m +sql insert into $table values (now + $ms , 10) +$x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then +return -1 +endi + +print =================== step 8 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +$y = $x + $N +$expect = $N * 7 +while $x < $y + $ms = $x . m + sql insert into $table values (now + $ms , 10) + $x = $x + 1 +endw + +sql select * from $table +print sql select * from $table -> $rows points +if $rows != $expect then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop + + diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/unique/vnode/replica3_repeat.sim new file mode 100644 index 0000000000..299036dace --- /dev/null +++ b/tests/script/unique/vnode/replica3_repeat.sim @@ -0,0 +1,86 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/ip.sh -i 4 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/deploy.sh -n dnode4 -m 192.168.0.1 -i 192.168.0.4 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode4 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mgmtEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mgmtEqualVnodeNum -v 4 + +system sh/exec.sh -n dnode1 -s start + +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +sql create dnode 192.168.0.4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sleep 3000 + +print ========= step1 +sql create database db replica 3 +sql create table db.tb (ts timestamp, i int) +sql insert into db.tb values(now, 1) +sql select count(*) from db.tb +$lastRows = $rows + +print ======== step2 +run_back cluster/vnode/back_insert.sim +sleep 3000 + +print ======== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +$x = 0 +loop: + +print ======== step4 +system sh/exec.sh -n dnode2 -s start +sleep 5000 +system sh/exec.sh -n dnode3 -s stop +sleep 5000 + +print ======== step5 +system sh/exec.sh -n dnode3 -s start +sleep 5000 +system sh/exec.sh -n dnode4 -s stop +sleep 5000 + +print ======== step6 +system sh/exec.sh -n dnode4 -s start +sleep 5000 +system sh/exec.sh -n dnode2 -s stop +sleep 5000 + +print ======== step7 +sql select count(*) from db.tb +print select count(*) from db.tb ==> $data00 $lastRows +if $data00 <= $lastRows then + return -1 +endi + +print ======== step8 +$lastRows = $data00 +print ======== loop Times $x + +if $x < 5 then + $x = $x + 1 + goto loop +endi + + diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim new file mode 100644 index 0000000000..a88c6854be --- /dev/null +++ b/tests/script/unique/vnode/replica3_vgroup.sim @@ -0,0 +1,67 @@ +system sh/stop_dnodes.sh +system sh/ip.sh -i 1 -s up +system sh/ip.sh -i 2 -s up +system sh/ip.sh -i 3 -s up +system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1 +system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2 +system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3 +system sh/cfg.sh -n dnode1 -c commitLog -v 0 +system sh/cfg.sh -n dnode2 -c commitLog -v 0 +system sh/cfg.sh -n dnode3 -c commitLog -v 0 +system sh/cfg.sh -n dnode1 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 + +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode 192.168.0.2 +sql create dnode 192.168.0.3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +$N = 10 +$table = table_r3 +$db = db1 + +sleep 3000 + +print =================== step 1 + +sql create database $db replica 3 tables 100 +sql use $db +sql create table st (ts timestamp, speed int) tags (t1 int) +sleep 3001 + + +$tbPre = m +$N = 280 +$x = 0 +$y = $x + $N +while $x < $y + $table = $tbPre . $x + sql create table $table using st tags ( $x ) + $ms = $x . m + sql insert into $table values (now + $ms , $x ) + $x = $x + 1 +endw + + +#print =================== step 2 +#$x = 1 +#$y = $x + $N +#$expect = $N +#while $x < $y +# $ms = $x . m +# sql insert into $table values (now + $ms , $x ) +# $x = $x + 1 +#endw + +#sql select * from $table +#print sql select * from $table -> $rows points +#if $rows != $expect then +# return -1 +#endi + + + diff --git a/tests/script/unique/vnode/testSuite.sim b/tests/script/unique/vnode/testSuite.sim new file mode 100644 index 0000000000..36e2c34c46 --- /dev/null +++ b/tests/script/unique/vnode/testSuite.sim @@ -0,0 +1,9 @@ +run cluster/vnode/replica2_basic2.sim +run cluster/vnode/replica2_basic.sim +run cluster/vnode/replica2_repeat.sim +run cluster/vnode/replica3_basic.sim +run cluster/vnode/replica3_repeat.sim +run cluster/vnode/commit.sim +run cluster/vnode/many.sim + + diff --git a/tests/script/windows/account/authority.sim b/tests/script/windows/account/authority.sim new file mode 100644 index 0000000000..f1a89ca704 --- /dev/null +++ b/tests/script/windows/account/authority.sim @@ -0,0 +1,317 @@ +sql connect +sleep 3000 + +print ============= step1 + +sql create user read pass 'taosdata' +sql create user write pass 'taosdata' +sql create user manage pass 'taosdata' + +sql create user a PASS 'ade' privilege -x step11 + return -1 +step11: + +sql create user a PASS 'ade' privilege a -x step12 + return -1 +step12: + +sql create user a PASS 'ade' privilege read -x step13 + return -1 +step13: + +sql show users +if $rows != 6 then + return -1 +endi + +sql alter user read privilege read +sql alter user write privilege write +sql alter user manage privilege super + +print ============= step2 +sql close +sql connect write +sleep 2000 + +sql create database d1 +sql create database d2 +sql create table d1.t1 (ts timestamp, i int) +sql create table d2.t2 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql insert into d2.t2 values(now, 1) +sql insert into d2.t2 values(now+1s, 2) + +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account t1 pass 'taosdata' -x step21 + return -1 +step21: + +sql create user t1 pass 'taosdata' -x step22 + return -1 +step22: + +sql alter user read pass 'taosdata' -x step23 + return -1 +step23: + +sql create dnode 192.168.0.2 -x step24 + return -1 +step24: + +sql drop dnode 192.168.0.2 -x step25 + return -1 +step25: + +sql create mnode 192.168.0.2 -x step26 + return -1 +step26: + +sql drop mnode 192.168.0.2 -x step27 + return -1 +step27: + +sql drop account root -x step28 + return -1 +step28: + +sql alter user write pass 'taosdata' + +print ============= step3 +sql close +sql connect read +sleep 2000 + +sql create database d3 -x step31 + return -1 +step31: + +sql create table d1.t3 (ts timestamp, i int) -x step32 + return -1 +step32: + +#sql insert into d1.t1 values(now, 2) -x step33 +# return -1 +#step33: + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi + +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql sql create account t1 pass 'taosdata' -x step34 + return -1 +step34: + +sql sql create user t1 pass 'taosdata' -x step35 + return -1 +step35: + +print ============= step4 +sql close +sql connect manage +sleep 2000 + +sql create database d3 +sql create database d4 +sql create table d3.t3 (ts timestamp, i int) +sql create table d4.t4 (ts timestamp, i int) + +sql show accounts +if $rows != 1 then + return -1 +endi +sql show users +if $rows != 6 then + return -1 +endi +sql show databases +if $rows != 4 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 +if $rows != 2 then + return -1 +endi + +sql create account other pass 'taosdata' -x step41 + return -1 +step41: + +sql close +sql connect +sleep 2000 +sql create account other pass 'taosdata' + +print ============= step5 +sql close +sql connect other +sleep 2000 +sql create user read pass 'taosdata' -x step51 + return -1 +step51: +sql create other write pass 'taosdata' -x step52 + return -1 +step52: + +sql create user oread pass 'taosdata' +sql create user owrite pass 'taosdata' +sql create user omanage pass 'taosdata' + +sql show users +print show users $rows +if $rows != 5 then + return -1 +endi + +sql alter user oread privilege read +sql alter user owrite privilege write +sql alter user oroot privilege super -x step53 + return -1 +step53: +sql alter user read privilege read -x step54 + return -1 +step54: + +print ============= step6 +sql close +sql connect owrite +sleep 2000 + +sql create database d1 +sql create database d3 +sql create table d1.t1 (ts timestamp, i int) +sql create table d3.t3 (ts timestamp, i int) +sql insert into d1.t1 values(now, 11) +sql insert into d3.t3 values(now, 11) +sql insert into d3.t3 values(now+1s, 12) + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step6 + return -1 +step6: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create user t1 pass 'taosdata' -x step62 + return -1 +step62: + +print ============= step7 +sql close +sql connect oread +sleep 2000 + +sql create database d7 -x step71 + return -1 +step71: + +sql show databases +if $rows != 2 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step72 + return -1 +step72: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +sql sql create user t1 pass 'taosdata' -x step74 + return -1 +step74: + +print ============= step8 +sql close +sql connect omanage +sleep 2000 + +sql create database d4 +sql create table d4.t4 (ts timestamp, i int) + +sql show databases +if $rows != 3 then + return -1 +endi +sql select * from d1.t1 +if $rows != 1 then + return -1 +endi +sql select * from d2.t2 -x step82 + return -1 +step82: +sql select * from d3.t3 +if $rows != 2 then + return -1 +endi + +print ============= step9 +sql close +sql connect +sleep 2000 +sql show databases +if $rows != 4 then + return -1 +endi + +sql drop user read +sql drop user manage +sql drop user write + +sql close +sql connect +sleep 2000 +sql drop database d1 +sql drop database d2 +sql drop database d3 +sql drop database d4 diff --git a/tests/script/windows/account/user_create.sim b/tests/script/windows/account/user_create.sim new file mode 100644 index 0000000000..aea95b7c5c --- /dev/null +++ b/tests/script/windows/account/user_create.sim @@ -0,0 +1,80 @@ +sql connect +sleep 3000 + +print =============== step1 +sql show users +if $rows != 3 then + return -1 +endi + +sql create user read PASS 'pass123' +sql create user read PASS 'pass123' -x step1 + return -1 +step1: + +sql show users +if $rows != 4 then + return -1 +endi + +sql alter user read PASS 'taosdata' + +print =============== step2 +sql close +sql connect read +sleep 2000 + +sql alter user read PASS 'taosdata' + +print =============== step3 +sql drop user read -x step31 + return -1 +step31: +sql drop user sys -x step32 + return -1 +step32: +sql drop user stream -x step33 + return -1 +step33: + +print =============== step4 +sql close +sql connect +sleep 2000 + +sql alter user read privilege read +sql show users +if $data1_read != read then + return -1 +endi + +sql alter user read privilege super +sql show users +if $data1_read != super then + return -1 +endi + +sql alter user read privilege write +sql show users +if $data1_read != write then + return -1 +endi + +sql alter user read privilege 1 -x step43 + return -1 +step43: + +sql drop user sys -x step41 + return -1 +step41: + +sql drop user stream -x step42 + return -1 +step42: + +sql drop user read + + + + + diff --git a/tests/script/windows/account/user_len.sim b/tests/script/windows/account/user_len.sim new file mode 100644 index 0000000000..b4a344fe8d --- /dev/null +++ b/tests/script/windows/account/user_len.sim @@ -0,0 +1,81 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_us_db +$tbPrefix = lm_us_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop user ac -x step0 + return -1 +step0: + +sql create user PASS '123' -x step1 + return -1 +step1: + +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step2 +sql drop user a -x step2 +step2: +sql create user a PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step3 +sql drop user abc01234567890123456789 -x step3 +step3: + +sql create user abc01234567890123456789 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user abc01234567890123456789 +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step4 +sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4 + return -1 +step4: +sql show users +if $rows != 3 then + return -1 +endi + +print =============== step5 +sql drop user 123 -x step5 +step5: +sql create user 123 PASS '123' -x step61 + return -1 +step61: + +sql create user a123 PASS '123' +sql show users +if $rows != 4 then + return -1 +endi + +sql drop user a123 +sql show users +if $rows != 3 then + return -1 +endi diff --git a/tests/script/windows/alter/metrics.sim b/tests/script/windows/alter/metrics.sim new file mode 100644 index 0000000000..7cfee695d0 --- /dev/null +++ b/tests/script/windows/alter/metrics.sim @@ -0,0 +1,776 @@ +sleep 3000 +sql connect + +print ======== step1 +sql create database d2 +sql use d2 +sql create table mt (ts timestamp, a int) TAGS (t int) +sql create table tb using mt tags (1) +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 * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi + +print ======== step2 +sql alter table mt add column b smallint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ======== step3 +sql alter table mt add column c tinyint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step4 +sql alter table mt add column d int +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step5 +sql alter table mt add column e bigint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step6 +sql alter table mt add column f float +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step7 +sql alter table mt add column g double +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step8 +sql alter table mt add column h binary(10) +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d2 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi +if $data90 != t then + return -1 +endi +if $data91 != INT then + return -1 +endi + +print ======== step11 +#sql alter table mt drop column a -x step111 +# return -1 +#step111: + +#sql alter table mt drop column ts -x step112 +# return -1 +#step112: + +#sql alter table mt drop column cdfg -x step113 +# return -1 +#step113: + +#sql alter table mt add column a -x step114 +# return -1 +#step114: + +#sql alter table mt add column b -x step115 +# return -1 +#step115: + +print ======== step12 +sql alter table mt drop column b +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi +if $data80 != t then + return -1 +endi +if $data81 != INT then + return -1 +endi + +print ======== step13 +sql alter table mt drop column c +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi +if $data70 != t then + return -1 +endi +if $data71 != INT then + return -1 +endi + +print ======== step14 +sql alter table mt drop column d +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi +if $data60 != t then + return -1 +endi +if $data61 != INT then + return -1 +endi + +print ======== step15 +sql alter table mt drop column e +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data51 != INT then + return -1 +endi + +print ======== step16 +sql alter table mt drop column f +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step17 +sql alter table mt drop column g +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi +if $data30 != t then + return -1 +endi +if $data31 != INT then + return -1 +endi + +print ============= step18 +sql alter table mt drop column h +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != null then + return -1 +endi + +print ======= over +sql drop database d2 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/alter/table.sim b/tests/script/windows/alter/table.sim new file mode 100644 index 0000000000..a05b6559dd --- /dev/null +++ b/tests/script/windows/alter/table.sim @@ -0,0 +1,679 @@ +sleep 3000 +sql connect + +print ======== step1 +sql create database d1 +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 * from tb +if $rows != 3 then + return -1 +endi +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi + +print ======== step2 +sql alter table tb add column b smallint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi + +print ======== step3 +sql alter table tb add column c tinyint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi + +print ======== step4 +sql alter table tb add column d int +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi + +print ======== step5 +sql alter table tb add column e bigint +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi + +print ======== step6 +sql alter table tb add column f float +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi + +print ======== step7 +sql alter table tb add column g double +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi + +print ======== step8 +sql alter table tb add column h binary(10) +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step9 +print ======== step10 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 3000 + +sql use d1 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data21 != SMALLINT then + return -1 +endi +if $data30 != c then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data40 != d then + return -1 +endi +if $data41 != INT then + return -1 +endi +if $data50 != e then + return -1 +endi +if $data51 != BIGINT then + return -1 +endi +if $data60 != f then + return -1 +endi +if $data61 != FLOAT then + return -1 +endi +if $data70 != g then + return -1 +endi +if $data71 != DOUBLE then + return -1 +endi +if $data80 != h then + return -1 +endi +if $data81 != BINARY then + return -1 +endi +if $data82 != 10 then + return -1 +endi + +print ======== step11 +sql alter table drop column a -x step111 + return -1 +step111: + +sql alter table drop column ts -x step112 + return -1 +step112: + +sql alter table drop column cdfg -x step113 + return -1 +step113: + +sql alter table add column a -x step114 + return -1 +step114: + +sql alter table add column b -x step115 + return -1 +step115: + +print ======== step12 +sql alter table tb drop column b +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != c then + return -1 +endi +if $data21 != TINYINT then + return -1 +endi +if $data30 != d then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data40 != e then + return -1 +endi +if $data41 != BIGINT then + return -1 +endi +if $data50 != f then + return -1 +endi +if $data51 != FLOAT then + return -1 +endi +if $data60 != g then + return -1 +endi +if $data61 != DOUBLE then + return -1 +endi +if $data70 != h then + return -1 +endi +if $data71 != BINARY then + return -1 +endi +if $data72 != 10 then + return -1 +endi + +print ======== step13 +sql alter table tb drop column c +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != d then + return -1 +endi +if $data21 != INT then + return -1 +endi +if $data30 != e then + return -1 +endi +if $data31 != BIGINT then + return -1 +endi +if $data40 != f then + return -1 +endi +if $data41 != FLOAT then + return -1 +endi +if $data50 != g then + return -1 +endi +if $data51 != DOUBLE then + return -1 +endi +if $data60 != h then + return -1 +endi +if $data61 != BINARY then + return -1 +endi +if $data62 != 10 then + return -1 +endi + +print ======== step14 +sql alter table tb drop column d +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != e then + return -1 +endi +if $data21 != BIGINT then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data40 != g then + return -1 +endi +if $data41 != DOUBLE then + return -1 +endi +if $data50 != h then + return -1 +endi +if $data51 != BINARY then + return -1 +endi +if $data52 != 10 then + return -1 +endi + +print ======== step15 +sql alter table tb drop column e +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != f then + return -1 +endi +if $data21 != FLOAT then + return -1 +endi +if $data30 != g then + return -1 +endi +if $data31 != DOUBLE then + return -1 +endi +if $data40 != h then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data42 != 10 then + return -1 +endi + +print ======== step16 +sql alter table tb drop column f +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != g then + return -1 +endi +if $data21 != DOUBLE then + return -1 +endi +if $data30 != h then + return -1 +endi +if $data31 != BINARY then + return -1 +endi +if $data32 != 10 then + return -1 +endi + +print ======== step17 +sql alter table tb drop column g +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != h then + return -1 +endi +if $data21 != BINARY then + return -1 +endi +if $data22 != 10 then + return -1 +endi + +print ============= step18 +sql alter table tb drop column h +sleep 2500 +sql describe tb +if $data00 != ts then + return -1 +endi +if $data01 != TIMESTAMP then + return -1 +endi +if $data10 != a then + return -1 +endi +if $data11 != INT then + return -1 +endi +if $data20 != null then + return -1 +endi + +print ======= over +sql drop database d1 +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/compute/avg.sim b/tests/script/windows/compute/avg.sim new file mode 100644 index 0000000000..1374ca5a25 --- /dev/null +++ b/tests/script/windows/compute/avg.sim @@ -0,0 +1,151 @@ +sql connect +sleep 3000 + +$dbPrefix = m_av_db +$tbPrefix = m_av_tb +$mtPrefix = m_av_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select avg(tbcol) from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step3 +sql select avg(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +sql select avg(tbcol) as b from $tb +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step5 +sql select avg(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step6 +sql select avg(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select avg(tbcol) from $mt +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +print =============== step8 +sql select avg(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +sql select avg(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step9 +sql select avg(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi + +sql select avg(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 9.500000000 then + return -1 +endi + +print =============== step10 +sql select avg(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 9.500000000 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select avg(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1.000000000 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/bottom.sim b/tests/script/windows/compute/bottom.sim new file mode 100644 index 0000000000..e908c774e4 --- /dev/null +++ b/tests/script/windows/compute/bottom.sim @@ -0,0 +1,92 @@ +sql connect +sleep 3000 + +$dbPrefix = m_bo_db +$tbPrefix = m_bo_tb +$mtPrefix = m_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select bottom(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step3 +sql select bottom(tbcol, 1) from $tb where ts > now + 4m +print ===> $data01 +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select bottom(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step5 +sql select bottom(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +print =============== step6 +sql select bottom(tbcol, 2) as b from $tb where ts > now + 4m +print ===> $data01 $data11 +if $data01 != 5 then + return -1 +endi +if $data11 != 6 then + return -1 +endi + +sql select bottom(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/count.sim b/tests/script/windows/compute/count.sim new file mode 100644 index 0000000000..54544f0354 --- /dev/null +++ b/tests/script/windows/compute/count.sim @@ -0,0 +1,167 @@ +sql connect +sleep 3000 + +$dbPrefix = m_co_db +$tbPrefix = m_co_tb +$mtPrefix = m_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + + +sql select count(*) from $tb +print ===> select count(*) from $tb => $data00 +if $data00 != $rowNum then + return -1 +endi + +sql select count(tbcol) from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step3 +sql select count(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol) as b from $tb +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +print =============== step5 +sql select count(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi + +sql select count(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != $rowNum then + return -1 +endi + +print =============== step6 +sql select count(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(*) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +sql select count(tbcol) from $mt +print ===> $data00 +if $data00 != $totalNum then + return -1 +endi + +print =============== step8 +sql select count(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 25 then + return -1 +endi + +print =============== step9 +sql select count(tbcol) as b from $mt interval(1m) +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $data11 != 10 then + return -1 +endi + +sql select count(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 200 then + return -1 +endi + +print =============== step10 +sql select count(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != $rowNum then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data01 +if $data01 != 1 then + return -1 +endi +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/diff.sim b/tests/script/windows/compute/diff.sim new file mode 100644 index 0000000000..e9d76f8c78 --- /dev/null +++ b/tests/script/windows/compute/diff.sim @@ -0,0 +1,84 @@ +sql connect +sleep 3000 + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select diff(tbcol) from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step3 +sql select diff(tbcol) from $tb where ts > now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select diff(tbcol) from $tb where ts < now + 4m +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step4 +sql select diff(tbcol) as b from $tb +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +print =============== step5 +sql select diff(tbcol) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select diff(tbcol) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/first.sim b/tests/script/windows/compute/first.sim new file mode 100644 index 0000000000..7b6a831004 --- /dev/null +++ b/tests/script/windows/compute/first.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 + +$dbPrefix = m_fi_db +$tbPrefix = m_fi_tb +$mtPrefix = m_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select first(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select first(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select first(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select first(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +sql select first(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select first(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data41 != 4 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select first(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select first(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select first(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select first(tbcol) as b from $mt interval(1m) +print select first(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select first(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select first(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select first(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/interval.sim b/tests/script/windows/compute/interval.sim new file mode 100644 index 0000000000..d40c6ad0c9 --- /dev/null +++ b/tests/script/windows/compute/interval.sim @@ -0,0 +1,169 @@ +sql connect +sleep 3000 + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now + 4m interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts < now+40m and ts > now+1m interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now + 4m interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now-1m interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts < now+40m and ts > now+1m interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/last.sim b/tests/script/windows/compute/last.sim new file mode 100644 index 0000000000..4b686766ae --- /dev/null +++ b/tests/script/windows/compute/last.sim @@ -0,0 +1,152 @@ +sql connect +sleep 3000 + +$dbPrefix = m_la_db +$tbPrefix = m_la_tb +$mtPrefix = m_la_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select last(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select last(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select last(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select last(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select last(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select last(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select last(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select last(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select last(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select last(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select last(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select last(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/leastsquare.sim b/tests/script/windows/compute/leastsquare.sim new file mode 100644 index 0000000000..81f37c3228 --- /dev/null +++ b/tests/script/windows/compute/leastsquare.sim @@ -0,0 +1,93 @@ +sql connect +sleep 3000 + +$dbPrefix = m_le_db +$tbPrefix = m_le_tb +$mtPrefix = m_le_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 2 + $ms = 1000 + while $x < $rowNum + $ms = $ms + 1000 + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select leastsquares(tbcol, 1, 1) from $tb +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step3 +sql select leastsquares(tbcol, 1, 1) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step4 +sql select leastsquares(tbcol, 1, 1) as b from $tb +print ===> $data00 +if $data00 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step5 +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi + +sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi + +print =============== step6 +sql select leastsquares(tbcol, 1, 1) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != @(1.000000, 1.000000)@ then + return -1 +endi +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/max.sim b/tests/script/windows/compute/max.sim new file mode 100644 index 0000000000..60147358b3 --- /dev/null +++ b/tests/script/windows/compute/max.sim @@ -0,0 +1,152 @@ +sql connect +sleep 3000 + +$dbPrefix = m_ma_db +$tbPrefix = m_ma_tb +$mtPrefix = m_ma_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select max(tbcol) from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step3 +sql select max(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step4 +sql select max(tbcol) as b from $tb +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step5 +sql select max(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step6 +sql select max(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select max(tbcol) from $mt +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +print =============== step8 +sql select max(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +sql select max(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 4 then + return -1 +endi + +print =============== step9 +sql select max(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select max(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step10 +sql select max(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 19 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select max(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/min.sim b/tests/script/windows/compute/min.sim new file mode 100644 index 0000000000..928404babc --- /dev/null +++ b/tests/script/windows/compute/min.sim @@ -0,0 +1,152 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mi_db +$tbPrefix = m_mi_tb +$mtPrefix = m_mi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select min(tbcol) from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step3 +sql select min(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step4 +sql select min(tbcol) as b from $tb +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step5 +sql select min(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step6 +sql select min(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select min(tbcol) from $mt +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step8 +sql select min(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +sql select min(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +print =============== step9 +sql select min(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select min(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 0 then + return -1 +endi + +print =============== step10 +sql select min(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 0 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select min(tbcol) as b from $mt where ts < now + 4m interval(1m) group by tgcol +print ===> $data11 +if $data11 != 1 then + return -1 +endi +print ===> $rows +if $rows != 50 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/percentile.sim b/tests/script/windows/compute/percentile.sim new file mode 100644 index 0000000000..6068722b54 --- /dev/null +++ b/tests/script/windows/compute/percentile.sim @@ -0,0 +1,109 @@ +sql connect +sleep 3000 + +$dbPrefix = m_pe_db +$tbPrefix = m_pe_tb +$mtPrefix = m_pe_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select percentile(tbcol, 10) from $tb +print ===> $data00 +if $data00 != 1.900000000 then + return -1 +endi + +sql select percentile(tbcol, 20) from $tb +print ===> $data00 +if $data00 != 3.800000000 then + return -1 +endi + +sql select percentile(tbcol, 100) from $tb +print ===> $data00 +if $data00 != 19.000000000 then + return -1 +endi + +sql select percentile(tbcol, 110) from $tb -x step2 + return -1 +step2: + +print =============== step3 +sql select percentile(tbcol, 1) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +print =============== step4 +sql select percentile(tbcol, 1) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.140000000 then + return -1 +endi + +sql select percentile(tbcol, 5) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.700000000 then + return -1 +endi + +sql select percentile(tbcol, 0) as c from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/stddev.sim b/tests/script/windows/compute/stddev.sim new file mode 100644 index 0000000000..b5ba704bef --- /dev/null +++ b/tests/script/windows/compute/stddev.sim @@ -0,0 +1,91 @@ +sql connect +sleep 3000 + +$dbPrefix = m_st_db +$tbPrefix = m_st_tb +$mtPrefix = m_st_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select stddev(tbcol) from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step3 +sql select stddev(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.414213562 then + return -1 +endi + +print =============== step4 +sql select stddev(tbcol) as b from $tb +print ===> $data00 +if $data00 != 5.766281297 then + return -1 +endi + +print =============== step5 +sql select stddev(tbcol) as b from $tb interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi + +sql select stddev(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 5.766281297 then + return -1 +endi + +print =============== step6 +sql select stddev(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data01 +if $data01 != 0.000000000 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/sum.sim b/tests/script/windows/compute/sum.sim new file mode 100644 index 0000000000..39eb771f34 --- /dev/null +++ b/tests/script/windows/compute/sum.sim @@ -0,0 +1,152 @@ +sql connect +sleep 3000 + +$dbPrefix = m_su_db +$tbPrefix = m_su_tb +$mtPrefix = m_su_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select sum(tbcol) from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step3 +sql select sum(tbcol) from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 10 then + return -1 +endi + +print =============== step4 +sql select sum(tbcol) as b from $tb +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +print =============== step5 +sql select sum(tbcol) as b from $tb interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi + +sql select sum(tbcol) as b from $tb interval(1d) +print ===> $data01 +if $data01 != 190 then + return -1 +endi + +print =============== step6 +sql select sum(tbcol) as b from $tb where ts < now + 4m interval(1m) +print ===> $data11 +if $data11 != 1 then + return -1 +endi +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select sum(tbcol) from $mt +print ===> $data00 +if $data00 != 1900 then + return -1 +endi + +print =============== step8 +sql select sum(tbcol) as c from $mt where ts < now + 4m +print ===> $data00 +if $data00 != 100 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 +print ===> $data00 +if $data00 != 950 then + return -1 +endi + +sql select sum(tbcol) as c from $mt where tgcol < 5 and ts < now + 4m +print ===> $data00 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select sum(tbcol) as b from $mt interval(1m) +print ===> $data11 +if $data11 < 5 then + return -1 +endi + +sql select sum(tbcol) as b from $mt interval(1d) +print ===> $data01 +if $data01 != 1900 then + return -1 +endi + +print =============== step10 +sql select sum(tbcol) as b from $mt group by tgcol +print ===> $data00 +if $data00 != 190 then + return -1 +endi + +if $rows != $tbNum then + return -1 +endi + +print =============== step11 +sql select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print select sum(tbcol) as b from $mt where ts < now + 4m interval(1d) group by tgcol +print ===> $data01 +if $data01 != 10 then + return -1 +endi +if $rows != 10 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/compute/top.sim b/tests/script/windows/compute/top.sim new file mode 100644 index 0000000000..b64c24b03f --- /dev/null +++ b/tests/script/windows/compute/top.sim @@ -0,0 +1,92 @@ +sql connect +sleep 3000 + +$dbPrefix = m_to_db +$tbPrefix = m_to_tb +$mtPrefix = m_to_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select top(tbcol, 1) from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step3 +sql select top(tbcol, 1) from $tb where ts < now + 4m +print ===> $data01 +if $data01 != 4 then + return -1 +endi + +print =============== step4 +sql select top(tbcol, 1) as b from $tb +print ===> $data01 +if $data01 != 19 then + return -1 +endi + +print =============== step5 +sql select top(tbcol, 2) as b from $tb +print ===> $data01 $data11 +if $data01 != 18 then + return -1 +endi +if $data11 != 19 then + return -1 +endi + +print =============== step6 +sql select top(tbcol, 2) as b from $tb where ts < now + 4m +print ===> $data01 $data11 +if $data01 != 3 then + return -1 +endi +if $data11 != 4 then + return -1 +endi + +sql select top(tbcol, 122) as b from $tb -x step6 + return -1 +step6: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/db/basic.sim b/tests/script/windows/db/basic.sim new file mode 100644 index 0000000000..4222cfe3b2 --- /dev/null +++ b/tests/script/windows/db/basic.sim @@ -0,0 +1,191 @@ +sql connect +sleep 3000 +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_db_db +$tbPrefix = ob_db_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db replica 1 days 20 keep 2000 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 20 then + return -1 +endi +if $data07 != 1000 then + return -1 +endi + +print =============== step2 +sql create database $db +sql show databases +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql drop database $db + +print =============== step5 +sql create database $db replica 1 days 15 keep 1500 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +if $data00 != $db then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data05 != 15 then + return -1 +endi + +if $data07 != 1000 then + return -1 +endi + +print =============== step6 +sql use $db +sql create table $tb (ts timestamp, speed int) +$i = 1 +while $i < 4 + $db = $dbPrefix . $i + $tb = $tbPrefix . $i + sql create database $db + sql use $db + sql create table $tb (ts timestamp, speed int) + $i = $i + 1 +endw + +sql show databases +if $rows != 4 then + return -1 +endi + +$i = 4 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) -x step6 + return -1 +step6: + +print =============== step7 +$i = 0 +while $i < 5 + $db = $dbPrefix . $i + sql drop database $db + $i = $i + 1 +endw + +print =============== step8 +$i = 0 +$db = $dbPrefix . $i +$tb = $tbPrefix . $i +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step9 +sql drop database $db + +print =============== step10 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step12 +sql drop database $db + +print =============== step13 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values (now+1a, 0) +sql insert into $tb values (now+2a, 1) +sql insert into $tb values (now+3a, 2) +sql insert into $tb values (now+4a, 3) +sql insert into $tb values (now+5a, 4) +sql select * from $tb +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql drop database $db + +print =============== step15 +sql create database $db +sql use $db +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step16 +sql create table $tb (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi +sql select * from $tb +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/db/len.sim b/tests/script/windows/db/len.sim new file mode 100644 index 0000000000..32f6476177 --- /dev/null +++ b/tests/script/windows/db/len.sim @@ -0,0 +1,85 @@ +sql connect +sleep 3000 + +print =============== step1 +sql drop database dd + +sql create database -x step1 + return -1 +step1: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create database a +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create database a12345678 +sql show databases +if $rows != 1 then + return -1 +endi + +sql drop database a12345678 +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create database a012345678901201234567890120123456789012 -x step4 + return -1 +step4: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create database a;1 +sql drop database a +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create database a'1 -x step6 + return -1 +step6: + +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create database (a) -x step7 + return -1 +step7: +sql show databases +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create database a.1 -x step8 + return -1 +step8: +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/2.sim b/tests/script/windows/field/2.sim new file mode 100644 index 0000000000..3d4492083e --- /dev/null +++ b/tests/script/windows/field/2.sim @@ -0,0 +1,288 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_bt_db +$tbPrefix = fi_bt_tb +$mtPrefix = fi_bt_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol2 bool, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 and tbcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol order by tgcol desc +print $db +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/3.sim b/tests/script/windows/field/3.sim new file mode 100644 index 0000000000..fb7d60d12a --- /dev/null +++ b/tests/script/windows/field/3.sim @@ -0,0 +1,514 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_3_db +$tbPrefix = fi_3_tb +$mtPrefix = fi_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 int, tbcol3 float) TAGS(tgcol1 smallint, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/4.sim b/tests/script/windows/field/4.sim new file mode 100644 index 0000000000..f7ffa9807c --- /dev/null +++ b/tests/script/windows/field/4.sim @@ -0,0 +1,704 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_4_db +$tbPrefix = fi_4_tb +$mtPrefix = fi_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 float, tbcol4 double) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/5.sim b/tests/script/windows/field/5.sim new file mode 100644 index 0000000000..e408871693 --- /dev/null +++ b/tests/script/windows/field/5.sim @@ -0,0 +1,827 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_5_db +$tbPrefix = fi_5_tb +$mtPrefix = fi_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 tinyint, tbcol2 int, tbcol3 bigint, tbcol4 double, tbcol5 smallint) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/6.sim b/tests/script/windows/field/6.sim new file mode 100644 index 0000000000..d1551d63b5 --- /dev/null +++ b/tests/script/windows/field/6.sim @@ -0,0 +1,982 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_6_db +$tbPrefix = fi_6_tb +$mtPrefix = fi_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol1 smallint, tbcol2 bigint, tbcol3 smallint, tbcol4 bigint, tbcol5 float, tbcol6 bool) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 float, tgcol6 bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0, 0, 0, 0, 0, 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1, 1, 1, 1, 1, 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tbcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tbcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tbcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tbcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tbcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tbcol2 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol2 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol2 <> 0 and ts < now + 5m and ts < now + 5m and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tbcol3 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol3 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol3 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol5 <> 0 and ts < now + 5m and ts < now + 5m and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol1 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol1 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tbcol4 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol1 = 1 and tbcol5 = 1 and tbcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 1 and tbcol2 <> 1 and tbcol3 <> 1 and tbcol1 <> 1 and tbcol5 <> 1 and tbcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 = 0 and tbcol2 = 0 and tbcol3 = 0 and tbcol1 = 0 and tbcol5 = 0 and tbcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol4 <> 0 and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol4 <> 0 and ts < now + 5m and ts < now + 5m and tbcol2 <> 0 and tbcol3 <> 0 and tbcol1 <> 0 and tbcol5 <> 0 and tbcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where ts < now + 4m and tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol1 order by tgcol1 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol2 order by tgcol2 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 interval(1d) group by tgcol3 order by tgcol3 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 interval(1d) group by tgcol4 order by tgcol4 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 interval(1d) group by tgcol5 order by tgcol5 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 and tbcol2 = 1 and tbcol3 = 1 and tbcol4 = 1 and tbcol5 = 1 and tbcol6 = 1 interval(1d) group by tgcol6 order by tgcol6 desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/bigint.sim b/tests/script/windows/field/bigint.sim new file mode 100644 index 0000000000..9ccaeb3723 --- /dev/null +++ b/tests/script/windows/field/bigint.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_bi_db +$tbPrefix = fi_bi_tb +$mtPrefix = fi_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bigint) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/binary.sim b/tests/script/windows/field/binary.sim new file mode 100644 index 0000000000..cd75b63814 --- /dev/null +++ b/tests/script/windows/field/binary.sim @@ -0,0 +1,77 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_by_db +$tbPrefix = fi_by_tb +$mtPrefix = fi_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol binary(10)) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '0' ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , '1' ) + $x = $x + 1 + endw + $i = $i + 1 +endw + + +print =============== step2 + +sql select * from $mt where tbcol = '0' +if $rows != 100 then + return -1 +endi + +sql select * from $mt where ts > now + 4m and tbcol = '1' +if $rows != 75 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol -x step13 + return -1 +step13: + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol -x step14 + return -1 +step14: + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol -x step15 + return -1 +step15: + +#can't filter binary fields + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/bool.sim b/tests/script/windows/field/bool.sim new file mode 100644 index 0000000000..5f2c61475c --- /dev/null +++ b/tests/script/windows/field/bool.sim @@ -0,0 +1,154 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_bo_db +$tbPrefix = fi_bo_tb +$mtPrefix = fi_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol bool) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print select count(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = true interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/double.sim b/tests/script/windows/field/double.sim new file mode 100644 index 0000000000..ea7e075208 --- /dev/null +++ b/tests/script/windows/field/double.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_do_db +$tbPrefix = fi_do_tb +$mtPrefix = fi_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol double) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/float.sim b/tests/script/windows/field/float.sim new file mode 100644 index 0000000000..5be59bae3b --- /dev/null +++ b/tests/script/windows/field/float.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_fl_db +$tbPrefix = fi_fl_tb +$mtPrefix = fi_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol float) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/int.sim b/tests/script/windows/field/int.sim new file mode 100644 index 0000000000..d7d26b7341 --- /dev/null +++ b/tests/script/windows/field/int.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/single.sim b/tests/script/windows/field/single.sim new file mode 100644 index 0000000000..0199133ecd --- /dev/null +++ b/tests/script/windows/field/single.sim @@ -0,0 +1,211 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_si_db +$tbPrefix = fi_si_tb +$mtPrefix = fi_si_mt +$rowNum = 20 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql create database $db +sql use $db +sql create table $tb (ts timestamp, tbcol int) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + +print =============== step2 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi + +sql select * from $tb where tbcol = 10 +if $rows != 1 then + return -1 +endi +if $data01 != 10 then + return -1 +endi + +sql select * from $tb where tbcol = 8 +if $rows != 1 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from $tb where tbcol < 10 +if $rows != 10 then + return -1 +endi +if $data91 != 9 then + return -1 +endi + +sql select * from $tb where tbcol <= 10 +if $rows != 11 then + return -1 +endi +if $data81 != 8 then + return -1 +endi + +sql select * from $tb where tbcol > 10 +if $rows != 9 then + return -1 +endi +if $data81 != 19 then + return -1 +endi + +sql select * from $tb where tbcol > 10 order by ts asc +if $rows != 9 then + return -1 +endi +if $data01 != 11 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 9 then + return -1 +endi +if $data31 != 6 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and tbcol > 5 order by ts asc +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi +if $data31 != 9 then + return -1 +endi + +sql select * from $tb where tbcol > 10 and tbcol < 5 order by ts asc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi + +sql select * from $tb where tbcol = 10 and ts < now + 4m +print select * from $tb where tbcol = 10 and ts < now + 4m +if $rows != 0 then + return -1 +endi + +sql select * from $tb where tbcol = 4 and ts < now + 4m order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts < now + 4m order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 4 then + return -1 +endi + +sql select * from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m order by ts desc +print $rows $data00 $data01 +if $rows != 1 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +print =============== step4 +sql select count(*) from $tb +if $data00 != $rowNum then + return -1 +endi + +sql select count(*) from $tb where tbcol = 10 +if $data00 != 1 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 8 or tbcol = 9 +#if $data00 != 2 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol < 10 +if $data00 != 10 then + return -1 +endi + +sql select count(*) from $tb where tbcol <= 10 +if $data00 != 11 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 +if $data00 != 4 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and tbcol > 5 order by ts asc -x step4 +# return -1 +step4: + +print =============== step5 +sql select count(*) from $tb where ts < now + 4m +if $data00 != 5 then + return -1 +endi + +#sql select count(*) from $tb where tbcol = 10 and ts < now + 4m +#if $data00 != 0 then +# return -1 +#endi + +sql select count(*) from $tb where tbcol = 4 and ts < now + 4m +if $data00 != 1 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts < now + 4m +if $data00 != 5 then + return -1 +endi + +sql select count(*) from $tb where tbcol < 10 and ts > now + 4m and ts < now + 5m +if $data00 != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/smallint.sim b/tests/script/windows/field/smallint.sim new file mode 100644 index 0000000000..8bee463292 --- /dev/null +++ b/tests/script/windows/field/smallint.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_sm_db +$tbPrefix = fi_sm_tb +$mtPrefix = fi_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol smallint) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/field/tinyint.sim b/tests/script/windows/field/tinyint.sim new file mode 100644 index 0000000000..65bffca095 --- /dev/null +++ b/tests/script/windows/field/tinyint.sim @@ -0,0 +1,153 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = fi_ti_db +$tbPrefix = fi_ti_tb +$mtPrefix = fi_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol tinyint) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 0 ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , 1 ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tbcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step3 +sql select * from $mt where ts > now + 4m and tbcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tbcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/import/basic.sim b/tests/script/windows/import/basic.sim new file mode 100644 index 0000000000..0621721a6b --- /dev/null +++ b/tests/script/windows/import/basic.sim @@ -0,0 +1,117 @@ +sql connect +sleep 3000 + +sql create database ibadb +sql use ibadb +sql create table tb(ts timestamp, i int) + +print ================= step1 +sql import into tb values(10000, 10000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step2 +sql insert into tb values(8000, 8000) +sql select * from tb; +if $rows != 1 then + return -1 +endi + +print ================= step3 +sql insert into tb values(20000, 20000) +sql select * from tb; +if $rows != 2 then + return -1 +endi + +print ================= step4 +sql import into tb values(8000, 8000) +sql import into tb values(15000, 15000) +sql import into tb values(30000, 30000) +sql select * from tb; +if $rows != 5 then + return -1 +endi + +print ================= step5 +sql insert into tb values(8000, 8000) +sql insert into tb values(14000, 14000) +sql insert into tb values(25000, 25000) +sql insert into tb values(40000, 40000) +sql select * from tb; +if $rows != 6 then + return -1 +endi + +print ================= step6 +sql import into tb values(7000, 7000) +sql import into tb values(12000, 12000) +sql import into tb values(23000, 23000) +sql import into tb values(34000, 34000) +sql import into tb values(50000, 50000) +sql select * from tb; +if $rows != 11 then + return -1 +endi + +print ================= step7 +sql import into tb values(7001, 7001) +sql import into tb values(12001, 12001) +sql import into tb values(23001, 23001) +sql import into tb values(34001, 34001) +sql import into tb values(50001, 50001) +sql select * from tb; +if $rows != 16 then + return -1 +endi + +print ================= step8 +sql insert into tb values(8002, 8002) +sql insert into tb values(14002, 14002) +sql insert into tb values(25002, 25002) +sql insert into tb values(200000, 60000) +sql select * from tb; +if $rows != 17 then + return -1 +endi + +print ================= step9 only insert last one +sql import into tb values(5000, 5000)(18000, 18000)(700000, 700000) +sql select * from tb; +if $rows != 18 then + return -1 +endi + +print ================= step10 +sql import into tb values(5000, 5000)(18000, 18000)(700000, 70000) +sql select * from tb; +if $rows != 19 then + return -1 +endi + +print ================= step11 +sql import into tb values(700000, 700000) +sql select * from tb; +if $rows != 19 then + return -1 +endi + +print ================= step12 +sql import into tb values(9527, 9527)(9527, 9528) +sql select * from tb; +print rows=> $rows +if $rows != 21 then + return -1 +endi + +print ================= step13 +sql import into tb values(9898, 9898)(9897, 9897) +sql select * from tb; +print rows=> $rows +if $rows != 23 then + return -1 +endi + +sql drop database ibadb \ No newline at end of file diff --git a/tests/script/windows/insert/basic.sim b/tests/script/windows/insert/basic.sim new file mode 100644 index 0000000000..42fdf87098 --- /dev/null +++ b/tests/script/windows/insert/basic.sim @@ -0,0 +1,42 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_in_db +$tbPrefix = tb_in_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$x = 0 +while $x < 10 + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +print =============== step 2 +sql insert into $tb values (now - 5m , 10) -x error_insert +sql insert into $tb values (now - 6m , 10) -x error_insert +sql insert into $tb values (now - 7m , 10) -x error_insert +sql insert into $tb values (now - 8m , 10) -x error_insert +error_insert: + +sql select * from $tb + +print $rows points data are retrieved +if $rows != 10 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/insert/query_block1_file.sim b/tests/script/windows/insert/query_block1_file.sim new file mode 100644 index 0000000000..3eb1d402e8 --- /dev/null +++ b/tests/script/windows/insert/query_block1_file.sim @@ -0,0 +1,188 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_1f_db +$tbPrefix = tb_1f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , - $x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$R = 4 +$x = $N * 2 +$y = $N * $R +$expect = $y + $N +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 3 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/insert/query_block1_memory.sim b/tests/script/windows/insert/query_block1_memory.sim new file mode 100644 index 0000000000..60d31e52d6 --- /dev/null +++ b/tests/script/windows/insert/query_block1_memory.sim @@ -0,0 +1,170 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_1m_db +$tbPrefix = tb_1m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int) + +#commit to file will trigger if insert 82 rows + +$N = 82 + +print =============== step 1 +$x = $N +$y = $N / 2 +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , -$x ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N / 2 +$y = $N +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $N then + return -1 +endi + +print =============== step 2 + +$N1 = $N + 1 +$result1 = $N / 2 +$result2 = $N +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/insert/query_block2_file.sim b/tests/script/windows/insert/query_block2_file.sim new file mode 100644 index 0000000000..e9f562a538 --- /dev/null +++ b/tests/script/windows/insert/query_block2_file.sim @@ -0,0 +1,203 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_2f_db +$tbPrefix = tb_2f_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows +$N = 82 + +print =============== step 1 +$x = $N * 2 +$y = $N +$expect = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$R = 4 +$y = $N * $R + +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x + +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$N2 = $N +$result1 = $N +$result2 = 2 * $N +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/insert/query_block2_memory.sim b/tests/script/windows/insert/query_block2_memory.sim new file mode 100644 index 0000000000..fd173f1356 --- /dev/null +++ b/tests/script/windows/insert/query_block2_memory.sim @@ -0,0 +1,165 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_2m_db +$tbPrefix = tb_2m_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed int) + +$N = 82 + +$x = $N * 2 +$y = $N +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $y then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 + +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/insert/query_file_memory.sim b/tests/script/windows/insert/query_file_memory.sim new file mode 100644 index 0000000000..e9b0c69ea5 --- /dev/null +++ b/tests/script/windows/insert/query_file_memory.sim @@ -0,0 +1,202 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_fm_db +$tbPrefix = tb_fm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +#commit to file will trigger if insert 82 rows + +$N = 82 + +$x = $N * 2 +$y = $N +$expect = $y +while $x > $y + $ms = $x . m + $xt = - . $x + sql insert into $tb values (now - $ms , $xt ) + $x = $x - 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$x = $N +$y = $N * 2 +$expect = $N * 2 +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + +$R = 4 +$R = $R - 1 + +$y = $N * $R +$expect = $y + $N +$expect = $expect + $N + +$x = $N * 3 +$y = $y + $x +while $x < $y + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 +endw + +sql select * from $tb +print sql select * from $tb -> $rows points +if $rows != $expect then + return -1 +endi + + +print =============== step 2 + +$result1 = $N +$result2 = $N * 2 +$N1 = $result2 + 1 +$step = $N1 . m + +$start1 = now- . $step +$start2 = now +$start3 = now+ . $step +$end1 = now- . $step +$end2 = now +$end3 = now+ . $step + + +sql select * from $tb where ts < $start1 and ts > $end1 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 +print select * from $tb where ts < $start2 and ts > $end1 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 +print sql select * from $tb where ts < $start3 and ts > $end1 -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 +print sql select * from $tb where ts < $start3 and ts > $end2 -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 +if $rows != 0 then + return -1 +endi + +print ================= order by ts desc + +sql select * from $tb where ts < $start1 and ts > $end1 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start1 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end1 order by ts desc +print select * from $tb where ts < $start2 and ts > $end1 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end2 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start2 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end1 order by ts desc -> $rows points +if $rows != $result2 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc +print sql select * from $tb where ts < $start3 and ts > $end2 order by ts desc -> $rows points +if $rows != $result1 then + return -1 +endi + +sql select * from $tb where ts < $start3 and ts > $end3 order by ts desc +if $rows != 0 then + return -1 +endi + +clear: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/windows/insert/query_multi_file.sim b/tests/script/windows/insert/query_multi_file.sim new file mode 100644 index 0000000000..3170b43582 --- /dev/null +++ b/tests/script/windows/insert/query_multi_file.sim @@ -0,0 +1,48 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = tb_mf_db +$tbPrefix = tb_mf_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database -x step1 +step1: +sql create database $db +sql use $db + +$x = 0 +create1: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi +sql create table $tb (ts timestamp, speed int) -x create1 + +$N = 20000 + +$x = 0 + +while $x < $N + $ms = $x . m + #print insert into $tb values (now + $ms , $x ) + sql insert into $tb values (now + $ms , $x ) -x error_insert + $x = $x + 1 +endw +error_insert: + +sql select * from $tb +print $rows points data are retrieved -> exepct $N rows +if $rows < $N then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + diff --git a/tests/script/windows/table/binary.sim b/tests/script/windows/table/binary.sim new file mode 100644 index 0000000000..1f3df987bb --- /dev/null +++ b/tests/script/windows/table/binary.sim @@ -0,0 +1,55 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_bn_db +$tbPrefix = lm_bn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed binary(5)) + +sql insert into $tb values (now, ) -x step1 + return -1 +step1: + +print =============== step2 +sql insert into $tb values (now+1a, '1234') +sql select speed from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, '23456') +sql select speed from $tb order by ts desc +if $rows != 2 then + return -1 +endi +print ==> $data00 +if $data00 != 23456 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, '345678') +sql select speed from $tb order by ts desc +if $rows != 3 then + return -1 +endi +print ==> $data00 +if $data00 != 34567 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/bool.sim b/tests/script/windows/table/bool.sim new file mode 100644 index 0000000000..afaaf46f51 --- /dev/null +++ b/tests/script/windows/table/bool.sim @@ -0,0 +1,85 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_bo_db +$tbPrefix = lm_bo_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +$x = 0 +sql create table $tb (ts timestamp, speed bool) + +sql insert into $tb values (now, true) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +print =============== step2 +sql insert into $tb values (now+1m, 1) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2m, 2) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3m, 0) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi + +if $data01 != false then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4m, -1) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5m, false) +sql select * from $tb order by ts desc +if $rows != 6 then + return -1 +endi + +if $data01 != false then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/column_name.sim b/tests/script/windows/table/column_name.sim new file mode 100644 index 0000000000..bbac293fed --- /dev/null +++ b/tests/script/windows/table/column_name.sim @@ -0,0 +1,83 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_cm_db +$tbPrefix = lm_cm_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table $tb(ts timestamp, int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, s int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a0123456789012345678901234567890123456789 int) +sql drop table $tb + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table $tb (ts timestamp, a0123456789 int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql insert into $tb values (now , 1) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/windows/table/column_num.sim b/tests/script/windows/table/column_num.sim new file mode 100644 index 0000000000..f7ead41437 --- /dev/null +++ b/tests/script/windows/table/column_num.sim @@ -0,0 +1,78 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_cn_db +$tbPrefix = lm_cn_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb() -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp) -x step2 + return -1 +step2: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts int) -x step3 + return -1 +step3: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int, b7 int, b8 int, b9 int, b10 int, b11 int, b12 int, b13 int, b14 int, b15 int, b16 int, b17 int, b18 int, b19 int, b20 int, b21 int, b22 int, b23 int, b24 int, b25 int, b26 int, b27 int, b28 int,b29 int,b30 int,b31 int,b32 int) + +sql show tables +if $rows != 1 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql create table $tb (ts timestamp, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, a10 int, a11 int, a12 int, a13 int, a14 int, a15 int, a16 int, a17 int, a18 int, a19 int, a20 int, a21 int, a22 int, a23 int, a24 int, a25 int, a26 int, a27 int, a28 int,a29 int,a30 int,a31 int,a32 int, b1 int, b2 int, b3 int, b4 int, b5 int) + +sql show tables +if $rows != 2 then + return -1 +endi + +sql insert into $tb values (now, 1 , 2 , 3 , 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) +sql select * from $tb +if $rows != 1 then + return -1 +endi + +sql drop table $tb +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/column_value.sim b/tests/script/windows/table/column_value.sim new file mode 100644 index 0000000000..d3b120d08e --- /dev/null +++ b/tests/script/windows/table/column_value.sim @@ -0,0 +1,75 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_cv_db +$tbPrefix = lm_cv_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql create table $tb (ts timestamp, speed int, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+1a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table $tb (ts timestamp, speed bigint, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -x step2 + return -1 +step2: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table $tb (ts timestamp, speed float, v1 binary(100), v2 binary(100), v3 binary(100), v4 binary(100), v5 binary(100)) +sql show tables +if $rows != 1 then + return -1 +endi +sql insert into $tb values(now+2a, 1, '1', '2', '3', '4', '5') +sql insert into $tb values(now+3a, 1, '1', '2', '3', '4', '5') +sql select * from $tb +if $rows != 2 then + return -1 +endi +sql drop table $tb +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table $tb (ts timestamp, speed double, v1 binary(1500), v2 binary(1500), v3 binary(1500), v4 binary(500), v5 binary(500)) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + + + diff --git a/tests/script/windows/table/db.table.sim b/tests/script/windows/table/db.table.sim new file mode 100644 index 0000000000..8d244e011f --- /dev/null +++ b/tests/script/windows/table/db.table.sim @@ -0,0 +1,40 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_dt_db +$tbPrefix = lm_dt_tb +$db = $dbPrefix +$tb = $tbPrefix + +print =============== step1 +sql create database $db +$table = lm_dt_db.lm_dt_tb + +print =============== step2 +sql create table $table (ts timestamp, speed int) + +print =============== step3 +sql insert into $table values (now, 1) + +print =============== step4 +sql select * from $table +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step5 +sql describe $table + +print =============== step6 +sql drop table $table + + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/table/double.sim b/tests/script/windows/table/double.sim new file mode 100644 index 0000000000..1402982c98 --- /dev/null +++ b/tests/script/windows/table/double.sim @@ -0,0 +1,91 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_do_db +$tbPrefix = lm_do_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed double) +#sql insert into $tb values (now, -1.79E+308) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 1.79E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.850000000 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.400000000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step51 + return -1 +step51: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.000000000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values(now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values(now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.000000000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/float.sim b/tests/script/windows/table/float.sim new file mode 100644 index 0000000000..4188f62166 --- /dev/null +++ b/tests/script/windows/table/float.sim @@ -0,0 +1,91 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_fl_db +$tbPrefix = lm_fl_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, speed float) +#sql insert into $tb values (now, -3.40E+38) -x step1 +# return -1 +#step1: + +print =============== step2 +#sql insert into $tb values (now+1a, 3.40E+308) -x step2 +# return -1 +#step2: + +sql select * from $tb order by ts desc +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql insert into $tb values (now+2a, 2.85) +sql select * from $tb order by ts desc +if $rows != 1 then + return -1 +endi +if $data01 != 2.8500 then + return -1 +endi + +print =============== step4 +sql insert into $tb values (now+3a, 3.4) +sql select * from $tb order by ts desc +if $rows != 2 then + return -1 +endi +if $data01 != 3.4000 then + return -1 +endi + +print =============== step5 +sql insert into $tb values (now+4a, a2) -x step5 + return -1 +step5: +sql insert into $tb values (now+4a, 0) +sql select * from $tb order by ts desc +if $rows != 3 then + return -1 +endi +if $data01 != 0.0000 then + return -1 +endi + +print =============== step6 +sql insert into $tb values (now+5a, 2a) -x step6 + return -1 +step6: +sql insert into $tb values (now+5a, 2) +sql select * from $tb order by ts desc +if $rows != 4 then + return -1 +endi +if $data01 != 2.0000 then + return -1 +endi + +print =============== step7 +sql insert into $tb values (now+6a, 2a'1) -x step7 + return -1 +step7: +sql insert into $tb values (now+6a, 2) +sql select * from $tb order by ts desc +if $rows != 5 then + return -1 +endi +if $data01 != 2.0000 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi diff --git a/tests/script/windows/table/table.sim b/tests/script/windows/table/table.sim new file mode 100644 index 0000000000..fe93fec6cd --- /dev/null +++ b/tests/script/windows/table/table.sim @@ -0,0 +1,218 @@ +sql connect +sleep 3000 +print ============================ dnode1 start + +$i = 0 +$dbPrefix = ob_tb_db +$tbPrefix = ob_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql drop database $db -x step1 +step1: +sql create database $db + +print =============== step2-3-4 +sql use $db + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.0000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step5 +sql show tables +if $rows != 7 then + return -1 +endi + +$i = 1 +while $i < 8 + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6-9 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 1, 1) +sql select * from $tb +if $data01 != 1 then + return -1 +endi + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val smallint, val2 smallint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 2, 2) +sql select * from $tb +if $data01 != 2 then + return -1 +endi + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val int, val2 int) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 3, 3) +sql select * from $tb +if $data01 != 3 then + return -1 +endi + +$i = 4 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val bigint, val2 bigint) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 4, 4) +sql select * from $tb +if $data01 != 4 then + return -1 +endi + +$i = 5 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val float, val2 float) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 5, 5) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 5.0000 then + return -1 +endi + +$i = 6 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val double, val2 double) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, 6, 6) +sql select * from $tb +print ==> $data01 $data02 +if $data01 != 6.000000000 then + return -1 +endi + +$i = 7 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val binary(20), val2 binary(20)) +sql select * from $tb +if $rows != 0 then + return -1 +endi +sql insert into $tb values(now, '7', '7') +sql select * from $tb +if $data01 != 7 then + return -1 +endi + +print =============== step10 +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, val tinyint, val2 tinyint) +sql show tables +if $rows != 7 then + return -1 +endi + +print =============== step11 +sql create table $tb (ts timestamp, val float, val2 double) +sql show tables +if $rows != 7 then + return -1 +endi + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + + diff --git a/tests/script/windows/table/table_len.sim b/tests/script/windows/table/table_len.sim new file mode 100644 index 0000000000..b792044b40 --- /dev/null +++ b/tests/script/windows/table/table_len.sim @@ -0,0 +1,98 @@ +sql connect +sleep 3000 + +$i = 0 +$dbPrefix = lm_tb_db +$tbPrefix = lm_tb_tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +print =============== step1 +sql create database $db +sql use $db + +sql drop table dd -x step0 + return -1 +step0: + +sql create table (ts timestamp, speed int) -x step1 + return -1 +step1: + +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step2 +sql create table a (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step3 +sql create table a0123456789 (ts timestamp, speed int) +sql show tables +if $rows != 1 then + return -1 +endi + +sql drop table a0123456789 +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step4 +sql create table ab01234567890123456789a0123456789a0123456789ab01234567890123456789a0123456789a0123456789 (ts timestamp, speed int) -x step4 + return -1 +step4: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step5 +sql create table a;1 (ts timestamp, speed int) -x step5 + return -1 +step5: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step6 +sql create table a'1 (ts timestamp, speed int) -x step6 + return -1 +step6: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step7 +sql create table (a) (ts timestamp, speed int) -x step7 + return -1 +step7: +sql show tables +if $rows != 0 then + return -1 +endi + +print =============== step8 +sql create table a.1 (ts timestamp, speed int) -x step8 + return -1 +step8: + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/3.sim b/tests/script/windows/tag/3.sim new file mode 100644 index 0000000000..9ffa11b03f --- /dev/null +++ b/tests/script/windows/tag/3.sim @@ -0,0 +1,514 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_3_db +$tbPrefix = ta_3_tb +$mtPrefix = ta_3_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> false +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step16 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step17 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = true and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/4.sim b/tests/script/windows/tag/4.sim new file mode 100644 index 0000000000..beabe1fd8f --- /dev/null +++ b/tests/script/windows/tag/4.sim @@ -0,0 +1,704 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_4_db +$tbPrefix = ta_4_tb +$mtPrefix = ta_4_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 bigint, tgcol3 float, tgcol4 double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step19 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step20 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/5.sim b/tests/script/windows/tag/5.sim new file mode 100644 index 0000000000..161d98756c --- /dev/null +++ b/tests/script/windows/tag/5.sim @@ -0,0 +1,827 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_5_db +$tbPrefix = ta_5_tb +$mtPrefix = ta_5_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 tinyint, tgcol2 int, tgcol3 bigint, tgcol4 double, tgcol5 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0, 0, 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1, 1, 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step22 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step23 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step24 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/6.sim b/tests/script/windows/tag/6.sim new file mode 100644 index 0000000000..b8666305bd --- /dev/null +++ b/tests/script/windows/tag/6.sim @@ -0,0 +1,982 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_6_db +$tbPrefix = ta_6_tb +$mtPrefix = ta_6_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 bigint, tgcol3 smallint, tgcol4 bigint, tgcol5 binary(30), tgcol6 binary(20)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', 0, 0, 0, '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', 1, 1, 1, '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol1 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where tgcol3 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol3 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step6 +sql select * from $mt where tgcol4 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol4 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step7 +sql select * from $mt where tgcol5 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol5 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step8 +sql select * from $mt where tgcol6 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol6 <> 1 +if $rows != 100 then + return -1 +endi + +print =============== step9 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step10 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step11 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step12 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step13 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step14 +sql select * from $mt where ts > now + 4m and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol6 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step15 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step16 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step17 +sql select * from $mt where ts > now + 4m and tgcol3 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol3 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol3 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step18 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol4 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol4 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol4 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol4 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step19 +sql select * from $mt where ts > now + 4m and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol5 <> 0 and ts < now + 5m and ts < now + 5m and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step20 +sql select * from $mt where ts > now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol1 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol1 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step21 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step22 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step23 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step24 +sql select * from $mt where ts > now + 4m and tgcol4 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol1 = 1 and tgcol5 = 1 and tgcol6 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 1 and tgcol2 <> 1 and tgcol3 <> 1 and tgcol1 <> 1 and tgcol5 <> 1 and tgcol6 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 = 0 and tgcol2 = 0 and tgcol3 = 0 and tgcol1 = 0 and tgcol5 = 0 and tgcol6 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol4 <> 0 and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol4 <> 0 and ts < now + 5m and ts < now + 5m and tgcol2 <> 0 and tgcol3 <> 0 and tgcol1 <> 0 and tgcol5 <> 0 and tgcol6 <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step25 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step26 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step27 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step28 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step29 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step30 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step31 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol2 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 interval(1d) group by tgcol3 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 interval(1d) group by tgcol4 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 interval(1d) group by tgcol5 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol1 = 1 and tgcol2 = 1 and tgcol3 = 1 and tgcol4 = 1 and tgcol5 = 1 and tgcol6 = 1 interval(1d) group by tgcol6 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/add.sim b/tests/script/windows/tag/add.sim new file mode 100644 index 0000000000..b734846686 --- /dev/null +++ b/tests/script/windows/tag/add.sim @@ -0,0 +1,844 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_ad_db +$tbPrefix = ta_ad_tb +$mtPrefix = ta_ad_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data33 != 2.000000 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.0000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tgcol4=false +sql alter table $tb set tgcol5=5 +sql alter table $tb set tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != false then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != false then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tgcol4=4 +sql alter table $tb set tgcol5=5 +sql alter table $tb set tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tgcol4=4 +sql alter table $tb set tgcol5=5 +sql alter table $tb set tgcol6=true +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print select * from $mt where tgcol5 = 5 +print $data01 $data02 $data03 $data04 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != true then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tgcol4=4 +sql alter table $tb set tgcol5=true +sql alter table $tb set tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = true +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != true then + return -1 +endi +if $data04 != 6.0000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tgcol4=4 +sql alter table $tb set tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != false then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.0000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tgcol4=4 +sql alter table $tb set tgcol5=5 +sql alter table $tb set tgcol6=6 +sql alter table $tb set tgcol7=7 +sql alter table $tb set tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.0000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tgcol1=false +sql alter table $tb set tgcol2=5 +sql alter table $tb set tgcol3=4 +sql alter table $tb set tgcol4=3 +sql alter table $tb set tgcol5=2 +sql alter table $tb set tgcol6=1 +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != false then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tgcol1=7 +sql alter table $tb set tgcol2=8 +sql alter table $tb set tgcol3=9 +sql alter table $tb set tgcol4=10 +sql alter table $tb set tgcol5=11 +sql alter table $tb set tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table $mt add tag tgcol3 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 bigint +sql alter table $mt add tag tgcol7 bigint -x step141 + return -1 +step141: +sql reset query cache +sql alter table $mt drop tag tgcol6 +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 bigint -x step142 + return -1 +step142: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bigint.sim b/tests/script/windows/tag/bigint.sim new file mode 100644 index 0000000000..4406c7386d --- /dev/null +++ b/tests/script/windows/tag/bigint.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_bi_db +$tbPrefix = ta_bi_tb +$mtPrefix = ta_bi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary.sim b/tests/script/windows/tag/binary.sim new file mode 100644 index 0000000000..deeae81117 --- /dev/null +++ b/tests/script/windows/tag/binary.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_by_db +$tbPrefix = ta_by_tb +$mtPrefix = ta_by_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/binary_binary.sim b/tests/script/windows/tag/binary_binary.sim new file mode 100644 index 0000000000..c1f93bc656 --- /dev/null +++ b/tests/script/windows/tag/binary_binary.sim @@ -0,0 +1,301 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_bib_db +$tbPrefix = ta_bib_tb +$mtPrefix = ta_bib_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0', '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1', '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> '0' +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> '0' +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool.sim b/tests/script/windows/tag/bool.sim new file mode 100644 index 0000000000..81ea20064b --- /dev/null +++ b/tests/script/windows/tag/bool.sim @@ -0,0 +1,231 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_bo_db +$tbPrefix = ta_bo_tb +$mtPrefix = ta_bo_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_binary.sim b/tests/script/windows/tag/bool_binary.sim new file mode 100644 index 0000000000..c3daf2c242 --- /dev/null +++ b/tests/script/windows/tag/bool_binary.sim @@ -0,0 +1,301 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_bob_db +$tbPrefix = ta_bob_tb +$mtPrefix = ta_bob_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/bool_int.sim b/tests/script/windows/tag/bool_int.sim new file mode 100644 index 0000000000..79e4b67bfa --- /dev/null +++ b/tests/script/windows/tag/bool_int.sim @@ -0,0 +1,317 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_boi_db +$tbPrefix = ta_boi_tb +$mtPrefix = ta_boi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> false +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> true +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = false +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> false +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> false and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> true +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/change.sim b/tests/script/windows/tag/change.sim new file mode 100644 index 0000000000..201c74c0bf --- /dev/null +++ b/tests/script/windows/tag/change.sim @@ -0,0 +1,506 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_ch_db +$tbPrefix = ta_ch_tb +$mtPrefix = ta_ch_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tagcx tgcol3 -x step21 + return -1 +step21: +sql alter table $mt change tag tgcol1 tgcol2 -x step22 + return -1 +step22: +sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 + return -1 +step20: + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 +sql alter table $mt change tag tgcol4 tgcol3 -x step23 + return -1 +step23: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt change tag tgcol1 tgcol3 +sql alter table $mt change tag tgcol2 tgcol4 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql reset query cache +sql alter table $mt change tag tgcol4 tgcol3 +sql alter table $mt change tag tgcol1 tgcol7 +sql alter table $mt change tag tgcol2 tgcol8 +sql reset query cache +sql alter table $mt change tag tgcol3 tgcol9 +sql alter table $mt change tag tgcol5 tgcol10 +sql alter table $mt change tag tgcol6 tgcol11 + +sleep 5000 +sql reset query cache + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step24 + return -1 +step24: +sql select * from $mt where tgcol2 = 1 -x step25 + return -1 +step25: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step31 + return -1 +step31: +sql select * from $mt where tgcol2 = 1 -x step32 + return -1 +step32: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step41 + return -1 +step41: +sql select * from $mt where tgcol2 = 1 -x step42 + return -1 +step42: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +sql select * from $mt where tgcol4 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol2 = 1 -x step52 + return -1 +step52: + +sql select * from $mt where tgcol3 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select * from $mt where tgcol4 = '2' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 -x step61 + return -1 +step61: +sql select * from $mt where tgcol2 = 1 -x step62 + return -1 +step62: +sql select * from $mt where tgcol3 = 1 -x step63 + return -1 +step63: +sql select * from $mt where tgcol4 = 1 -x step64 + return -1 +step64: +sql select * from $mt where tgcol5 = 1 -x step65 + return -1 +step65: +sql select * from $mt where tgcol6 = 1 -x step66 + return -1 +step66: + +sql select * from $mt where tgcol7 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol8 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol9 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol10 = 5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol11 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 4 then + return -1 +endi +if $data05 != 5.000000000 then + return -1 +endi +if $data06 != 6 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/column.sim b/tests/script/windows/tag/column.sim new file mode 100644 index 0000000000..131f3e06ea --- /dev/null +++ b/tests/script/windows/tag/column.sim @@ -0,0 +1,86 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_co_db +$tbPrefix = ta_co_tb +$mtPrefix = ta_co_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db + +$i = 0 +sql create table $mt (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10)) + +print =============== step2 + +$i = 0 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 0, '0' ) + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '2', '2' ) + +$i = 3 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( '3', 3 ) + +sql show tables +if $rows != 4 then + return -1 +endi + +print =============== step3 + +$i = 0 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 0, '0') + +$i = 1 +$tb = $tbPrefix . $i +sql insert into $tb values(now, 1, 1 ) + +$i = 2 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '2', '2') + +$i = 3 +$tb = $tbPrefix . $i +sql insert into $tb values(now, '3', 3) + +print =============== step4 +sql select * from $mt where tgcol2 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step5 +sql select * from $mt +if $rows != 4 then + return -1 +endi + +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/create.sim b/tests/script/windows/tag/create.sim new file mode 100644 index 0000000000..e7f7163160 --- /dev/null +++ b/tests/script/windows/tag/create.sim @@ -0,0 +1,591 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_cr_db +$tbPrefix = ta_cr_tb +$mtPrefix = ta_cr_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) +sql create table $tb using $mt tags( 1 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 0 then + return -1 +endi + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) +sql create table $tb using $mt tags( '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol = '0' +if $rows != 0 then + return -1 +endi + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi +print =============== step15 +$i = 15 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step16 +$i = 16 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step17 +$i = 17 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = true +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step18 +$i = 18 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step19 +$i = 19 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step20 +$i = 20 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step21 +$i = 21 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step22 +$i = 22 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step23 +$i = 23 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 0 then + return -1 +endi + +print =============== step24 +$i = 24 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol4 = 4 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol5 = 5 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step25 +$i = 25 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol6 = '6' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol6 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step26 +$i = 26 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4', '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql select * from $mt where tgcol3 = '0' +if $rows != 0 then + return -1 +endi + +print =============== step27 +$i = 27 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27 + return -1 +step27: + +print =============== step28 +$i = 28 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step29 +$i = 29 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250)) +sql create table $tb using $mt tags('1', '1') +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +print =============== step30 +$i = 30 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30 + return -1 +step30: + +print =============== step31 +$i = 31 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5)) +sql create table $tb using $mt tags('1234567') +sql insert into $tb values(now, 1) +sql select * from $mt +print sql select * from $mt +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data02 != 12345 then + return -1 +endi diff --git a/tests/script/windows/tag/delete.sim b/tests/script/windows/tag/delete.sim new file mode 100644 index 0000000000..d671b61abe --- /dev/null +++ b/tests/script/windows/tag/delete.sim @@ -0,0 +1,818 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_de_db +$tbPrefix = ta_de_tb +$mtPrefix = ta_de_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 < 3 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != 1 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step40 + return -1 +step40: +sql alter table $mt drop tag tgcol2 + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol1 -x step50 + return -1 +step50: +sql alter table $mt drop tag tgcol2 + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql describe $tb +if $data21 != SMALLINT then + return -1 +endi +if $data31 != TINYINT then + return -1 +endi +if $data41 != BINARY then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data32 != 1 then + return -1 +endi +if $data42 != 10 then + return -1 +endi +if $data23 != 1 then + return -1 +endi +if $data33 != 2 then + return -1 +endi +if $data43 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, '2', '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.0000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.0000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol5 +sql alter table $mt drop tag tgcol6 + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 + +sleep 5000 + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step51 + return -1 +step51: +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol1 = '1' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != null then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: +sql select * from $mt where tgcol4 = 1 -x step103 + return -1 +step103: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4=4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 4.0000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol5 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 4.000000000 then + return -1 +endi +if $data04 != null then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step120 + return -1 +step120: +sql select * from $mt where tgcol3 = 1 -x step121 + return -1 +step121: +sql select * from $mt where tgcol5 = 1 -x step122 + return -1 +step122: +sql select * from $mt where tgcol6 = 1 -x step123 + return -1 +step123: + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i + +sql reset query cache +sql select * from $mt where tgcol2 = 2 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 5.000000000 then + return -1 +endi +if $data05 != null then + return -1 +endi +if $data06 != null then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step130 + return -1 +step130: +sql select * from $mt where tgcol4 = 1 -x step131 + return -1 +step131: +sql select * from $mt where tgcol6 = 1 -x step133 + return -1 +step133: + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table xxmt drop tag tag1 -x step141 + return -1 +step141: +sql alter table $tb drop tag tag1 -x step142 + return -1 +step142: +sql alter table $mt drop tag tag1 -x step143 + return -1 +step143: + +sql alter table $mt drop tag tagcol1 -x step144 + return -1 +step144: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol1 -x step145 + return -1 +step145: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/double.sim b/tests/script/windows/tag/double.sim new file mode 100644 index 0000000000..c08351a41b --- /dev/null +++ b/tests/script/windows/tag/double.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_do_db +$tbPrefix = ta_do_tb +$mtPrefix = ta_do_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/filter.sim b/tests/script/windows/tag/filter.sim new file mode 100644 index 0000000000..72a8e39dc8 --- /dev/null +++ b/tests/script/windows/tag/filter.sim @@ -0,0 +1,145 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_fi_db +$tbPrefix = ta_fi_tb +$mtPrefix = ta_fi_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 + return -1 +step2: + +print =============== step3 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 + return -1 +step3: + +print =============== step4 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi + +print =============== step5 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 + return -1 +step6: + +print =============== step7 +sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 + return -1 +step7: + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol -x step8 + return -1 +step8: + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 + return -1 +step9: + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol) as c from $mt group by tbcol -x step11 + return -1 +step11: + +print =============== step12 +sql select count(tbcol) as c from $mt group by noexist -x step12 + return -1 +step12: + +print =============== step13 +sql select count(tbcol) as c from $mt group by tgcol +print $data00 +if $data00 != 100 then + return -1 +endi + +print =============== step14 +sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step15 +sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 + return -1 +step15: + +print =============== step16 +sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/float.sim b/tests/script/windows/tag/float.sim new file mode 100644 index 0000000000..79eabb2cb4 --- /dev/null +++ b/tests/script/windows/tag/float.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_fl_db +$tbPrefix = ta_fl_tb +$mtPrefix = ta_fl_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int.sim b/tests/script/windows/tag/int.sim new file mode 100644 index 0000000000..d3921218fd --- /dev/null +++ b/tests/script/windows/tag/int.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_in_db +$tbPrefix = ta_in_tb +$mtPrefix = ta_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_binary.sim b/tests/script/windows/tag/int_binary.sim new file mode 100644 index 0000000000..96f4f18966 --- /dev/null +++ b/tests/script/windows/tag/int_binary.sim @@ -0,0 +1,301 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_inb_db +$tbPrefix = ta_inb_tb +$mtPrefix = ta_inb_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 binary(5)) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, '0' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, '1' ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 = '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '0' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = '1' +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> '1' +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = '1' and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> '0' and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = '1' group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/int_float.sim b/tests/script/windows/tag/int_float.sim new file mode 100644 index 0000000000..768e86b96d --- /dev/null +++ b/tests/script/windows/tag/int_float.sim @@ -0,0 +1,317 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_inf_db +$tbPrefix = ta_inf_tb +$mtPrefix = ta_inf_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0, 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1, 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step3 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol2 > 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 < 0.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol2 <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step7 +sql select * from $mt where ts > now + 4m and tgcol2 = 1 and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 and tgcol2 = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + + +print =============== step13 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + +print =============== step14 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/set.sim b/tests/script/windows/tag/set.sim new file mode 100644 index 0000000000..7f8cf3b0a7 --- /dev/null +++ b/tests/script/windows/tag/set.sim @@ -0,0 +1,450 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_se_db +$tbPrefix = ta_se_tb +$mtPrefix = ta_se_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != true then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tag tagcx 1 -x step21 + return -1 +step21: +sql alter table $tb set tgcol1=false +sql alter table $tb set tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = false +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != false then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != false then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql describe $tb +print $data21 $data23 $data32 $data33 +if $data21 != BOOL then + return -1 +endi +if $data31 != INT then + return -1 +endi +if $data23 != false then + return -1 +endi +if $data33 != 4 then + return -1 +endi + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tgcol1=3 +sql alter table $tb set tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 2 +if $rows != 0 then + return -1 +endi + + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.0000 then + return -1 +endi + +sql alter table $tb set tgcol1=3 +sql alter table $tb set tgcol2=4 + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.0000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3 then + return -1 +endi +if $data03 != 4.0000 then + return -1 +endi + + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $tb set tgcol1=3 +sql alter table $tb set tgcol2='4' + +sql reset query cache + +sql select * from $mt where tgcol1 = 3 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol3 +sql alter table $tb set tgcol1='7' +sql alter table $tb set tgcol2=8 +sql alter table $tb set tgcol4='9' +sql alter table $tb set tgcol5=10 +sql alter table $tb set tgcol6='11' + +sql reset query cache + +sql select * from $mt where tgcol1 = '7' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 8 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol4 = '9' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol5 = 10 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +sql select * from $mt where tgcol6 = '11' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi +if $data04 != 9 then + return -1 +endi +if $data05 != 10.000000000 then + return -1 +endi +if $data06 != 11 then + return -1 +endi +if $data07 != null then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/smallint.sim b/tests/script/windows/tag/smallint.sim new file mode 100644 index 0000000000..1b7ff0860b --- /dev/null +++ b/tests/script/windows/tag/smallint.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_sm_db +$tbPrefix = ta_sm_tb +$mtPrefix = ta_sm_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/tag/tinyint.sim b/tests/script/windows/tag/tinyint.sim new file mode 100644 index 0000000000..8fe957664c --- /dev/null +++ b/tests/script/windows/tag/tinyint.sim @@ -0,0 +1,234 @@ +sql connect +sleep 3000 +print ======================== dnode1 start + +$dbPrefix = ta_ti_db +$tbPrefix = ta_ti_tb +$mtPrefix = ta_ti_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint) + +$i = 0 +while $i < 5 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 0 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw +while $i < 10 + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( 1 ) + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + $i = $i + 1 +endw + +print =============== step2 +sleep 100 +sql select * from $tb +if $rows != $rowNum then + return -1 +endi +sql select * from $tb where ts < now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts <= now + 4m +if $rows != 5 then + return -1 +endi +sql select * from $tb where ts > now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts >= now + 4m +if $rows != 15 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 5m +if $rows != 1 then + return -1 +endi +sql select * from $tb where ts < now + 4m and ts > now + 5m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > 100000 and ts < 100000 +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts < now + 3m +if $rows != 0 then + return -1 +endi +sql select * from $tb where ts > now + 4m and ts > now + 5m and ts < now + 6m +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql select * from $mt +if $rows != $totalNum then + return -1 +endi + +sql select * from $mt where ts < now + 4m +if $rows != 50 then + return -1 +endi +sql select * from $mt where ts > now + 4m +if $rows != 150 then + return -1 +endi +sql select * from $mt where ts = now + 4m +if $rows != 0 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m +if $rows != 10 then + return -1 +endi + +print =============== step4 +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 1 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol = 0 +if $rows != 100 then + return -1 +endi +sql select * from $mt where tgcol <> 0 +if $rows != 100 then + return -1 +endi + +print =============== step5 +sql select * from $mt where ts > now + 4m and tgcol = 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 1 +if $rows != 75 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts < now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol = 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts <= now + 4m and tgcol <> 0 +if $rows != 25 then + return -1 +endi +sql select * from $mt where ts > now + 4m and ts < now + 5m and tgcol <> 0 +if $rows != 5 then + return -1 +endi +sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts < now + 5m +if $rows != 5 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 200 then + return -1 +endi + +print =============== step7 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step8 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 50 then + return -1 +endi + +print =============== step9 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step10 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 100 then + return -1 +endi + +print =============== step11 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data00 != 25 then + return -1 +endi + + +print =============== step12 +sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by tgcol +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +if $data01 != 100 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/testSuite.sim b/tests/script/windows/testSuite.sim new file mode 100644 index 0000000000..9aa7147ef6 --- /dev/null +++ b/tests/script/windows/testSuite.sim @@ -0,0 +1,97 @@ +run windows/account/user_create.sim +run windows/account/user_len.sim + +run windows/db/len.sim + +run windows/table/table.sim +run windows/table/table_len.sim +run windows/table/column_num.sim +run windows/table/column_name.sim +run windows/table/column_value.sim +run windows/table/binary.sim +run windows/table/bool.sim +run windows/table/double.sim +run windows/table/float.sim +run windows/table/db.table.sim + +run windows/import/basic.sim + +run windows/alter/table.sim +run windows/alter/metrics.sim + +run windows/compute/count.sim +run windows/compute/avg.sim +run windows/compute/sum.sim +run windows/compute/min.sim +run windows/compute/max.sim +run windows/compute/first.sim +run windows/compute/last.sim +run windows/compute/stddev.sim +#run windows/compute/leastsquare.sim +run windows/compute/top.sim +run windows/compute/bottom.sim +run windows/compute/percentile.sim +run windows/compute/diff.sim +run windows/compute/interval.sim + +run windows/field/single.sim +run windows/field/bool.sim +run windows/field/smallint.sim +run windows/field/tinyint.sim +run windows/field/int.sim +run windows/field/bigint.sim +run windows/field/float.sim +run windows/field/double.sim +run windows/field/binary.sim +run windows/field/2.sim +run windows/field/3.sim +run windows/field/4.sim +run windows/field/5.sim +run windows/field/6.sim + +run windows/tag/filter.sim +run windows/tag/column.sim +run windows/tag/bool.sim +run windows/tag/smallint.sim +run windows/tag/tinyint.sim +run windows/tag/int.sim +run windows/tag/bigint.sim +run windows/tag/float.sim +run windows/tag/double.sim +run windows/tag/binary.sim +run windows/tag/bool_int.sim +run windows/tag/bool_binary.sim +run windows/tag/int_float.sim +run windows/tag/int_binary.sim +run windows/tag/binary_binary.sim +run windows/tag/3.sim +run windows/tag/4.sim +run windows/tag/5.sim +run windows/tag/6.sim +run windows/tag/create.sim +#run windows/tag/delete.sim + +#run windows/tag/set.sim +#run windows/tag/add.sim + +run windows/vector/single.sim +run windows/vector/multi.sim +run windows/vector/table_query.sim +run windows/vector/table_time.sim +run windows/vector/table_field.sim +run windows/vector/table_mix.sim +run windows/vector/metrics_query.sim +run windows/vector/metrics_tag.sim +run windows/vector/metrics_time.sim +run windows/vector/metrics_field.sim +run windows/vector/metrics_mix.sim + +run windows/insert/basic.sim +run windows/insert/query_block1_memory.sim +run windows/insert/query_block2_memory.sim +run windows/insert/query_block1_file.sim +#run windows/insert/query_block2_file.sim +#run windows/insert/query_file_memory.sim +#run windows/insert/query_multi_file.sim + +run windows/tag/change.sim diff --git a/tests/script/windows/vector/metrics_field.sim b/tests/script/windows/vector/metrics_field.sim new file mode 100644 index 0000000000..8e9a87239e --- /dev/null +++ b/tests/script/windows/vector/metrics_field.sim @@ -0,0 +1,615 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mf_db +$tbPrefix = m_mf_tb +$mtPrefix = m_mf_mt + +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_mix.sim b/tests/script/windows/vector/metrics_mix.sim new file mode 100644 index 0000000000..0f960deb4d --- /dev/null +++ b/tests/script/windows/vector/metrics_mix.sim @@ -0,0 +1,615 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mx_db +$tbPrefix = m_mx_tb +$mtPrefix = m_mx_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - ffrom $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step020 + return -1 +step020: + +sql select a -f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where a = 5 and tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_query.sim b/tests/script/windows/vector/metrics_query.sim new file mode 100644 index 0000000000..a0df4c9b04 --- /dev/null +++ b/tests/script/windows/vector/metrics_query.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mq_db +$tbPrefix = m_mq_tb +$mtPrefix = m_mq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt -x step21 + return -1 +step21: + +sql select h - f from $mt -x step22 + return -1 +step22: + +sql select ts - f from $mt -x step23 + return -1 +step23: + +sql select a - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_tag.sim b/tests/script/windows/vector/metrics_tag.sim new file mode 100644 index 0000000000..22fd19bc89 --- /dev/null +++ b/tests/script/windows/vector/metrics_tag.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mtg_db +$tbPrefix = m_mtg_tb +$mtPrefix = m_mtg_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/metrics_time.sim b/tests/script/windows/vector/metrics_time.sim new file mode 100644 index 0000000000..da102b64a3 --- /dev/null +++ b/tests/script/windows/vector/metrics_time.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mt_db +$tbPrefix = m_mt_tb +$mtPrefix = m_mt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/multi.sim b/tests/script/windows/vector/multi.sim new file mode 100644 index 0000000000..969ba5aa19 --- /dev/null +++ b/tests/script/windows/vector/multi.sim @@ -0,0 +1,209 @@ +sql connect +sleep 3000 + +$dbPrefix = m_mu_db +$tbPrefix = m_mu_tb +$mtPrefix = m_mu_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f binary(10), g bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + e from $tb where ts < now + 4m order by ts desc + +sql select a + a from $tb where ts > now + 4m order by ts desc + +sql select a + c from $tb where ts < now + 4m order by ts asc + +sql select a + f from $tb where ts > now + 4m order by ts asc -x step24 + return -1 +step24: + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - e from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select a - b from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * b + e from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select a * b + c from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a * b -d from $tb where ts > now + 4m +print ===> $data20 +if $data20 != 42.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / 2 + e from $tb +print ===> $data00 +if $data00 != 10.500000000 then + return -1 +endi + +sql select a / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 1.000000000 then + return -1 +endi + +sql select a / 2 * e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i +sql select a + ts from $tb -x step61 + return -1 +step61: + +sql select a + f from $tb -x step62 + return -1 +step62: + +sql select a + g from $tb -x step63 + return -1 +step63: + +print =============== step7 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + b from $tb where a = 2 +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select * from $tb where b < 2 +print ===> $rows +if $rows != 1 then + return -1 +endi + +sql select * from $tb where b > 2 +print ===> $rows +if $rows != 17 then + return -1 +endi + +sql select a + c from $tb where b = 2 and ts < now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +sql select a + d from $tb where c = 10 and ts > now + 4m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where d = 2 and ts < now + 4m order by ts desc + +sql select a + a from $tb where e = 2 and ts > now + 4m order by ts desc + +sql select a + c from $tb where f = 2 and ts < now + 4m order by ts asc + +sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step74 + return -1 +step74: + + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/single.sim b/tests/script/windows/vector/single.sim new file mode 100644 index 0000000000..61135fc6b5 --- /dev/null +++ b/tests/script/windows/vector/single.sim @@ -0,0 +1,295 @@ +sql connect +sleep 3000 + +$dbPrefix = m_si_db +$tbPrefix = m_si_tb +$mtPrefix = m_si_mt + +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol + 1 from $tb +print ===> $data00 $data10 $data20 $data30 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 6.000000000 then + return -1 +endi + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts desc + +sql select tbcol + 1 from $tb where ts < now + 4m order by ts asc + +sql select tbcol + 1 from $tb where ts > now + 4m order by ts asc + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol - 1 from $tb +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != -1.000000000 then + return -1 +endi + +sql select tbcol - 1 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 4.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts < now + 4m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol * 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts < now + 4m +print ===> $data10 +if $data10 != 0.500000000 then + return -1 +endi + +sql select tbcol / 2 from $tb where ts > now + 4m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select tbcol / 0 from $tb where ts > now + 4m +print ===> $data00 +#if $data00 != 0.000000000 then +# return -1 +#endi + +print =============== step6 +$i = 11 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bool) +sql insert into $tb values(now, 0) +sql select tbcol + 2 from $tb -x step6 + return -1 +step6: + +print =============== step7 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol tinyint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step8 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol smallint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step9 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol bigint) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step10 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol float) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step11 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol double) +sql insert into $tb values(now, 0); +sql select tbcol + 2 from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi +sql select tbcol - 2 from $tb +print ===> $data00 +if $data00 != -2.000000000 then + return -1 +endi +sql select tbcol * 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi +sql select tbcol / 2 from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step12 +$i = $i + 1 +$tb = $tbPrefix . $i +sql create table $tb (ts timestamp, tbcol binary(100)) +sql insert into $tb values(now, '0'); +sql select tbcol + 2 from $tb -x step12 + return -1 +step12: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_field.sim b/tests/script/windows/vector/table_field.sim new file mode 100644 index 0000000000..ec50bc7a2a --- /dev/null +++ b/tests/script/windows/vector/table_field.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_tf_db +$tbPrefix = m_tf_tb +$mtPrefix = m_tf_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select a / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_mix.sim b/tests/script/windows/vector/table_mix.sim new file mode 100644 index 0000000000..653171b302 --- /dev/null +++ b/tests/script/windows/vector/table_mix.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_tm_db +$tbPrefix = m_tm_tb +$mtPrefix = m_tm_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where a = 5 +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where a = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where a = 5 and ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_query.sim b/tests/script/windows/vector/table_query.sim new file mode 100644 index 0000000000..cdbd96f4d0 --- /dev/null +++ b/tests/script/windows/vector/table_query.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_tq_db +$tbPrefix = m_tq_tb +$mtPrefix = m_tq_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - a from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select b - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - b from $tb +print ===> $data00 +if $data00 != 9.000000000 then + return -1 +endi + +sql select c - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select d - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select e - f from $tb +print ===> $data00 +if $data00 != -9.000000000 then + return -1 +endi + +sql select f - f from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb -x step21 + return -1 +step21: + +sql select h - f from $tb -x step22 + return -1 +step22: + +sql select ts - f from $tb -x step23 + return -1 +step23: + +sql select a - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb = $tbPrefix . $i + +sql select a + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + a from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select b + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + b from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select c + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select d + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select e + f from $tb +print ===> $data00 +if $data00 != 11.000000000 then + return -1 +endi + +sql select f + f from $tb +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select d + e from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c + d from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + c from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select a + b from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b + a from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb = $tbPrefix . $i + +sql select a * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select e * f from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select f * f from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d * e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c * d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a * b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b * a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb = $tbPrefix . $i + +sql select a / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / a from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / b from $tb +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select d / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select e / f from $tb +print ===> $data00 +if $data00 != 0.100000000 then + return -1 +endi + +sql select f / f from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/windows/vector/table_time.sim b/tests/script/windows/vector/table_time.sim new file mode 100644 index 0000000000..48bcf86dca --- /dev/null +++ b/tests/script/windows/vector/table_time.sim @@ -0,0 +1,611 @@ +sql connect +sleep 3000 + +$dbPrefix = m_tt_db +$tbPrefix = m_tt_tb +$mtPrefix = m_tt_mt + +$tbNum = 10 +$rowNum = 21 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 1 + while $x < $rowNum + $ms = $x . m + sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select a - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select b - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 5.000000000 then + return -1 +endi + +sql select c - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select d - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select e - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select f - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select g - f from $tb where ts > now + 4m and ts < now + 6m -x step21 + return -1 +step21: + +sql select h - f from $tb where ts > now + 4m and ts < now + 6m -x step22 + return -1 +step22: + +sql select ts - f from $tb where ts > now + 4m and ts < now + 6m -x step23 + return -1 +step23: + +sql select a - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select d - e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select c - d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select a - b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +sql select b - a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.000000000 then + return -1 +endi + +print =============== step3 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select b + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select c + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select d + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select e + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 20.000000000 then + return -1 +endi + +sql select a + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select d + e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select c + d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select a + b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +sql select b + a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 10.000000000 then + return -1 +endi + +print =============== step4 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select b * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select c * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select d * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select e * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 50.000000000 then + return -1 +endi + +sql select f * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 100.000000000 then + return -1 +endi + +sql select a * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select d * e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select c * d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select a * b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +sql select b * a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 25.000000000 then + return -1 +endi + +print =============== step5 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select a / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select b / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.000000000 then + return -1 +endi + +sql select c / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select d / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select e / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.500000000 then + return -1 +endi + +sql select f / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select d / e from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select c / d from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / c from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select a / b from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +sql select b / a from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 1.000000000 then + return -1 +endi + +print =============== step6 +$i = 1 +$tb where ts > now + 4m and ts < now + 6m = $tbPrefix . $i + +sql select (a+b+c+d+e) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 2.500000000 then + return -1 +endi + +sql select f / (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 0.400000000 then + return -1 +endi + +sql select (a+b+c+d+e) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select f * (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 250.000000000 then + return -1 +endi + +sql select (a+b+c+d+e) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != 15.000000000 then + return -1 +endi + +sql select f - (a+b+c+d+e) from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -15.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) / f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1.500000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) * f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -150.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) + f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -5.000000000 then + return -1 +endi + +sql select (f - (a+b+c+d+e)) - f from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -25.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e) * f as zz from $tb where ts > now + 4m and ts < now + 6m +print ===> $data00 +if $data00 != -1300.000000000 then + return -1 +endi + +sql select (f - (a*b+c)*a + d + e))) * f as zz from $tb where ts > now + 4m and ts < now + 6m -x step61 + return -1 +step61: + +sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $tb where ts > now + 4m and ts < now + 6m -x step62 + return -1 +step62: + +sql select (f - (a*b+c)*a + d + e))) ** f as zz from $tb where ts > now + 4m and ts < now + 6m -x step63 + return -1 +step63: + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi \ No newline at end of file -- GitLab