提交 08e32652 编写于 作者: S Shengliang Guan

removde http testcases

上级 42243430
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ============================ dnode1 start
print =============== step1 - prepare data
sql create database db
sql use db
sql create table if not exists db.win_cpu(ts timestamp,f_percent_dpc_time double,f_percent_idle_time double,f_percent_interrupt_time double,f_percent_privileged_time double,f_percent_processor_time double,f_percent_user_time double) tags(t_host binary(32),t_instance binary(32),t_objectname binary(32));
print =============== step2 - auto create
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'import into db.win_cpu_windows_1_processor using db.win_cpu tags('windows','1','Processor') values(1564641722000,0.000000,95.598305,0.000000,0.000000,0.000000,0.000000);' 127.0.0.1:7111/rest/sql
print curl 127.0.0.1:7111/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
sql select * from db.win_cpu_windows_1_processor
print rows: $rows
if $rows != 1 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 ======================")
}
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032
system sh/exec.sh -n dnode1 -s start
sleep 2000
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)
print sql length is 270KB
restful d1 table_rest 1591072800 10000
restful d1 table_rest 1591172800 10000
restful d1 table_rest 1591272800 10000
restful d1 table_rest 1591372800 10000
restful d1 table_rest 1591472800 10000
restful d1 table_rest 1591572800 10000
restful d1 table_rest 1591672800 10000
restful d1 table_rest 1591772800 10000
restful d1 table_rest 1591872800 10000
restful d1 table_rest 1591972800 10000
sql select * from table_rest;
print rows: $rows
if $rows != 100000 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
#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 2000
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 127.0.0.1:7111/grafana/
print 1-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/grafana/xx
print 2-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/grafana/login/xx/xx/
print 3-> $system_content
if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/grafana/root/1/123/1/1/3
print 4-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/grafana/login/1/root/1/
print 5-> $system_content
if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then
return -1
endi
system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/grafana/root/1/login
print 6-> $system_content
if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then
return -1
endi
system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/grafana/root/1/login
print 7-> $system_content
if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then
return -1
endi
sleep 2000
system_content curl 127.0.0.1:7111/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:7111/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:7111/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:7111/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:7111/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:7111/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:7111/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:7111/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:7111/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:7111/grafana/query
print 16-> $system_content
if $system_content != @[{"refId":"A","target":"{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"{b: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:7111/grafana/query
print 17-> $system_content
if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[5,"-"]]},{"refId":"A","target":"count{a:2,}","datapoints":[[4,"-"]]},{"refId":"A","target":"count{a:3,}","datapoints":[[3,"-"]]},{"refId":"B","target":"sum-{b:a}","datapoints":[[5,"-"]]},{"refId":"B","target":"sum-{b:b}","datapoints":[[8,"-"]]},{"refId":"B","target":"sum-{b: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:7111/grafana/query
print 18-> $system_content
if $system_content != @[{"refId":"A","target":"count{a:1,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000],[1,1514208540000]]},{"refId":"A","target":"count{a:2,}","datapoints":[[1,1514208300000],[1,1514208360000],[1,1514208420000],[1,1514208480000]]},{"refId":"A","target":"count{a:3,}","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:7111/grafana/query
print 19-> $system_content
if $system_content != @[{"refId":"A","target":"{count(v1):3}","datapoints":[[15.299999714,"-"]]},{"refId":"B","target":"{sum(v2):15.299999714}","datapoints":[[3,"-"]]}]@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
#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 2000
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 create table tb3 (ts timestamp, val int, val1 int, val2 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)
sql insert into tb3 values('2020-01-01 00:00:00.000', NULL, NULL, NULL)
sql insert into tb3 values('2020-01-02 00:00:00.000', NULL, NULL, NULL)
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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,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:7111/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:7111/grafana/query
print step3.1-> $system_content
if $system_content != @[{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1: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:7111/grafana/query
print step3.2-> $system_content
if $system_content != @[{"refId":"A","target":"{val1:11,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1: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:7111/grafana/query
print step3.3-> $system_content
if $system_content != @[{"refId":"A","target":"{val:1,}","datapoints":[[11,1577808000000],[12,1577894400000]]},{"refId":"A","target":"{val: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:7111/grafana/query
print step4.1-> $system_content
if $system_content != @[{"refId":"A","target":"{val1:11,, val:1,}","datapoints":[[21,1577808000000]]},{"refId":"A","target":"{val1:12,, val:1,}","datapoints":[[22,1577894400000]]},{"refId":"A","target":"{val1:13,, val:2,}","datapoints":[[23,1577980800000]]},{"refId":"A","target":"{val1:14,, val:2,}","datapoints":[[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:7111/grafana/query
print step4.2-> $system_content
if $system_content != @[{"refId":"A","target":"{val1:11,, val2:21,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,, val2:22,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,, val2:23,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,, val2: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:7111/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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{val2:23,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2: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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{val2:21,, val:1,}","datapoints":[[11,"-"]]},{"refId":"A","target":"{val2:22,, val:1,}","datapoints":[[12,"-"]]},{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[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:7111/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:7111/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:7111/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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1: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:7111/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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB{val1:213,}","datapoints":[[223,1577980800000]]},{"refId":"B","target":"BB{val1:214,}","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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB{val1:213,, val2:223,, val1:213,}","datapoints":[[22,1577980800000]]},{"refId":"B","target":"BB{val1:214,, val2:224,, val1:214,}","datapoints":[[22,1578067200000]]},{"refId":"A","target":"AA{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"AA{val1:14,}","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:7111/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:7111/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:7111/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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[[null,1577980800000],[null,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:7111/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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA{val2:223,}","datapoints":[[213,1577980800000]]},{"refId":"A","target":"AA{val2:224,}","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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,}","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:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,, val2:223,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,, val2:224,}","datapoints":[[22,"-"]]}]@ then
return -1
endi
print =============== step26 - 2 column, no timestamp, NULL
system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select * from db.tb3 "} ]' 127.0.0.1:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{val1:nil, val2:nil}","datapoints":[[null,1577808000000],[null,1577894400000]]}]@ then
return -1
endi
sql create table tt (ts timestamp ,i int) tags(j binary(20),k binary(20));
sql insert into t1 using tt tags('jnetworki','t1') values('2020-01-01 00:00:00.000',1)('2020-01-01 00:01:00.000',2)('2020-01-01 00:02:00.000',3)('2020-01-01 00:03:00.000',4)('2020-01-01 00:04:00.000',5);
system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027%network%\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then
return -1
endi
system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027jnetwo%\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then
return -1
endi
system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select max(i) from db.tt where j like \u0027%networki\u0027 and ts >= \u00272020-01-01 00:00:00.000\u0027 and ts < \u00272020-01-01 00:05:00.000\u0027 interval(5m) group by k "} ]' 127.0.0.1:7111/grafana/query
print step1-> $system_content
if $system_content != @[{"refId":"A","target":"{k:t1}","datapoints":[[5,1577808000000]]}]@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032
system sh/exec.sh -n dnode1 -s start
sleep 2000
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)
print sql length is 270KB
restful d1 table_rest 1591072800 10000 gzip
restful d1 table_rest 1591172800 10000 gzip
restful d1 table_rest 1591272800 10000 gzip
restful d1 table_rest 1591372800 10000 gzip
restful d1 table_rest 1591472800 10000 gzip
restful d1 table_rest 1591572800 10000 gzip
restful d1 table_rest 1591672800 10000 gzip
restful d1 table_rest 1591772800 10000 gzip
restful d1 table_rest 1591872800 10000 gzip
restful d1 table_rest 1591972800 10000 gzip
sql select * from table_rest;
print rows: $rows
if $rows != 100000 then
return -1
endi
system curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql --compressed
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
{
"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
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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))
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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))
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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))
}
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
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:7111/rest/login/root/taosdata
print curl 127.0.0.1:7111/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:7111/rest/sql/d1
print curl 127.0.0.1:7111/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
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1
system sh/exec.sh -n dnode1 -s start
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:7111/rest/login/root/taosdata
print curl 127.0.0.1:7111/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:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"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:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"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:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"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:7111/rest/sql
print curl 127.0.0.1:7111/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:7111/rest/login/u1/abcd@1234
print curl 127.0.0.1:7111/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:7111/rest/login/u2/aabcd_1234
print curl 127.0.0.1:7111/rest/login/u2/abcd_1234 -----> $system_content
if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c httpDbNameMandatory -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
sql drop database if exists db
print ============================ dnode1 start
print =============== step1 - login
system_content curl 127.0.0.1:7111/rest/login/root/taosdata
print curl 127.0.0.1:7111/rest/login/root/taosdata -----> $system_content
if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then
return -1
endi
print =============== step2 - execute sql without db_name
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest (now, 1)' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest values (now, 1)' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql
if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then
return -1
endi
print =============== step3 - execute sql with db_name
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql/databases
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql/databases
if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql/db
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql/db
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql/db
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql/db
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest (now, 1)' 127.0.0.1:7111/rest/sql/db
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest values (1629904789233, 1)' 127.0.0.1:7111/rest/sql/db
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql/db
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql/db
if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2021-08-25 23:19:49.233",1]],"rows":1}@ then
return -1
endi
print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql/db
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql/db
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/exec.sh -n dnode1 -s start
#sleep 2000
sql connect
print ============================ dnode1 start
print =============== step1 - login
system_content curl 127.0.0.1:7111/rest/
print 1-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
print $system_content
return -1
endi
system_content curl 127.0.0.1:7111/rest/xx
print 2-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/rest/login
print 3-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
#4
system_content curl 127.0.0.1:7111/rest/login/root
print 4-> $system_content
if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/rest/login/root/123
print 5-> $system_content
if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then
return -1
endi
system_content curl 127.0.0.1:7111/rest/login/root/123/1/1/3
print 6-> $system_content
if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/login/root/1
print 7-> $system_content
if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then
return -1
endi
#8
system_content curl -H 'Authorization: Beare eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9' -d 'show databases' 127.0.0.1:7111/rest/login/root/1
print 8-> $system_content
if $system_content != @{"status":"error","code":4386,"desc":"invalid type of Authorization"}@ then
return -1
endi
system_content curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/rest/login/root/1
print 8-> $system_content
if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then
return -1
endi
system_content curl -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3d3cudGFvc2RhdGEuY29tIiwicGFzcyI6InRhb3NkYXRhIiwic3ViIjoicm9vdCJ9.xPv3b5odlR7YF8G_QWASjIRbMtA5v4ItToJ35fFgi' -d 'show databases' 127.0.0.1:7111/rest/login/root/1
print 9-> $system_content
if $system_content != @{"status":"error","code":4387,"desc":"invalid format of Authorization"}@ then
return -1
endi
sleep 2000
system_content curl 127.0.0.1:7111/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' 127.0.0.1:7111/rest/sql
print 11-> $system_content
if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep2","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep2",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql
print 12-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql
print 13-> $system_content
if $system_content != @{"status":"error","code":897,"desc":"Database already exists"}@ then
return -1
endi
#14
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '' 127.0.0.1:7111/rest/sql
print 14-> $system_content
if $system_content != @{"status":"error","code":4359,"desc":"no sql input"}@ then
return -1
endi
#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'use d1' 127.0.0.1:7111/rest/sql
#print 15-> $system_content
#if $system_content != @{"status":"error","code":5017,"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' 127.0.0.1:7111/rest/sql
#print 16-> $system_content
#if $system_content != @{"status":"error","code":5017,"desc":"no need to execute use db cmd"}@ then
# return -1
#endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' used1' 127.0.0.1:7111/rest/sql
print 17-> $system_content
if $system_content != @{"status":"error","code":534,"desc":"Syntax error in SQL"}@ then
return -1
endi
#18
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/rest/sql
print 18-> $system_content
if $system_content != @{"status":"error","code":896,"desc":"Database not specified or available"}@ then
return -1
endi
print =============== step3 - db
#19
#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/rest/sql/d4
#print 19-> $system_content
#if $system_content != @{"status":"error","code":1000,"desc":"invalid DB"}@ then
# return -1
#endi
#system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:7111/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;' 127.0.0.1:7111/rest/sql
print 21-> $system_content
if $system_content != @{"status":"error","code":866,"desc":"Table does not exist"}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
print 22-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 23-> $system_content
if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"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)" 127.0.0.1:7111/rest/sql
print 24-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 25-> $system_content
if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"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)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:43.022', 3)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:44.022', 4)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:45.022', 5)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:46.022', 6)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:47.022', 7)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:48.022', 8)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:49.022', 9)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:50.022', 10)" 127.0.0.1:7111/rest/sql
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d "insert into d1.t1 values('2017-12-25 21:28:51.022', 11)" 127.0.0.1:7111/rest/sql
#27
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1 ' 127.0.0.1:7111/rest/sql
print 27-> $system_content
if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"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' 127.0.0.1:7111/rest/sql
print 28-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
print 29-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"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)" 127.0.0.1:7111/rest/sql
print 30-> $system_content
if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d2.t1 ' 127.0.0.1:7111/rest/sql
print 31-> $system_content
if $system_content != @{"status":"succ","head":["ts","speed"],"column_meta":[["ts",9,8],["speed",4,4]],"data":[["2017-12-25 21:28:41.022",1]],"rows":1}@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
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:7111/rest/login/root/taosdata
print curl 127.0.0.1:7111/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.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:7111/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:7111/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:7111/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:7111/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:7111/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:7111/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:7111/rest/sql
print =============== step5 - query data
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest1' 127.0.0.1:7111/rest/sql
print curl 127.0.0.1:7111/rest/sql -----> $system_content
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
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:7111/rest/sql
print curl 127.0.0.1:7111/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:7111/rest/sql
#print curl 127.0.0.1:7111/rest/sql -----> $system_content
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
{
"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
}
{
"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
}
{
"hostIp": "192.168.0.1",
"machineNum": 100,
"loopNum": 100,
"dbName": "db",
"dataBegin": 1485878400000
}
{
"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
system sh/stop_dnodes.sh
sleep 2000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
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 2000
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:7111/telegraf/
print $system_content
if $system_content != @{"status":"error","code":4448,"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:7111/telegraf/
print $system_content
if $system_content != @{"status":"error","code":4448,"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:7111/telegraf/d123456789012345678901234567890123456
print $system_content
if $system_content != @{"status":"error","code":4449,"desc":"database name too long"}@ then
return -1
endi
system_content curl -u root:taosdata -d '[]' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then
return -1
endi
system_content curl -u root:taosdata -d '{}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then
return -1
endi
system_content curl -u root:taosdata -d '[{}]' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then
return -1
endi
system_content curl -u root:taosdata -d '{"metrics": []}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4451,"desc":"metrics size is 0"}@ then
return -1
endi
system_content curl -u root:taosdata -d '{"metrics": [{}]}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4453,"desc":"metric name not find"}@ then
return -1
endi
system_content curl -u root:taosdata -d '{"metrics": 12}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4451,"desc":"metrics size is 0"}@ then
return -1
endi
#system_content curl -u root:taosdata -d '{"metrics": [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}' 127.0.0.1:7111/telegraf/db/root/taosdata1
#print $system_content
#if $system_content != @{"status":"error","code":4452,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4453,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4454,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4455,"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":"a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234a1234567890123456789012345678901234","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4456,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4457,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4458,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4459,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4460,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4461,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4461,"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:7111/telegraf/db/root/taosdata
#print $system_content
#if $system_content != @{"status":"error","code":4461,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4461,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4464,"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:7111/telegraf/db/root/taosdata1
#print $system_content
#if $system_content != @{"status":"error","code":4465,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4466,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4467,"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":{"5022":"111"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4468,"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":"host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222host111111111111222222222222222222222"},"timestamp":1535784122}' 127.0.0.1:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4469,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4471,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4474,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4477,"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:7111/telegraf/db/root/taosdata1
print $system_content
if $system_content != @{"status":"error","code":4476,"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:7111/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 2000
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:7111/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
system_content curl -u root:taosdata -d 'select * from db.win_cpu_windows_1_Processor' 127.0.0.1:7111/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 06: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:7111/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:7111/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:7111/rest/sql/
print $system_content
if $system_content != @{"status":"succ","head":["count(*)"],"column_meta":[["count(*)",5,8]],"data":[[3]],"rows":1}@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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))
}
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
run general/http/autocreate.sim
run general/http/chunked.sim
run general/http/restful.sim
run general/http/restful_insert.sim
run general/http/restful_limit.sim
run general/http/restful_full.sim
run general/http/prepare.sim
run general/http/telegraf.sim
run general/http/grafana_bug.sim
run general/http/grafana.sim
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册