diff --git a/tests/gotest/batchtest.bat b/tests/gotest/batchtest.bat new file mode 100644 index 0000000000000000000000000000000000000000..abe9a58f319068d5e11017abcd721a4c54d6aca9 --- /dev/null +++ b/tests/gotest/batchtest.bat @@ -0,0 +1,17 @@ +@echo off +echo ==== start Go connector test cases test ==== +cd /d %~dp0 + +set severIp=%1 +set serverPort=%2 +if "%severIp%"=="" (set severIp=127.0.0.1) +if "%serverPort%"=="" (set serverPort=6030) + +cd case001 +case001.bat %severIp% %serverPort% + +rem cd case002 +rem case002.bat + +:: cd case002 +:: case002.bat diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh index a027dd0d7ce04c599233157bdd618fad3885c809..e8ed9ecbed9f70c98e6b5db052c3e69082c1794d 100644 --- a/tests/gotest/batchtest.sh +++ b/tests/gotest/batchtest.sh @@ -1,5 +1,18 @@ #!/bin/bash -bash ./case001/case001.sh -#bash ./case002/case002.sh -#bash ./case003/case003.sh +echo "==== start Go connector test cases test ====" + +severIp=$1 +serverPort=$2 + +if [ ! -n "$severIp" ]; then + severIp=127.0.0.1 +fi + +if [ ! -n "$serverPort" ]; then + serverPort=6030 +fi + +bash ./case001/case001.sh $severIp $serverPort +#bash ./case002/case002.sh $severIp $serverPort +#bash ./case003/case003.sh $severIp $serverPort diff --git a/tests/gotest/case001/case001.bat b/tests/gotest/case001/case001.bat new file mode 100644 index 0000000000000000000000000000000000000000..ebec576e724ccb14319dd380c9783a783ac0db62 --- /dev/null +++ b/tests/gotest/case001/case001.bat @@ -0,0 +1,9 @@ +@echo off +echo ==== start run cases001.go + +del go.* +go mod init demotest +go build +demotest.exe -h %1 -p %2 +cd .. + diff --git a/tests/gotest/case001/case001.go b/tests/gotest/case001/case001.go index 1d5ede6d21a0bacad34cb807a16b50e0ae643512..fb94f566dd7fa9ef8932bc28326310681998b410 100644 --- a/tests/gotest/case001/case001.go +++ b/tests/gotest/case001/case001.go @@ -16,20 +16,53 @@ package main import ( "database/sql" + "flag" "fmt" _ "github.com/taosdata/driver-go/taosSql" "log" + "strconv" "time" ) +type config struct { + hostName string + serverPort int + user string + password string +} + +var configPara config +var url string + +func init() { + flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.") + flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.") + flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.") + flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") + + flag.Parse() +} + +func printAllArgs() { + fmt.Printf("\n============= args parse result: =============\n") + fmt.Printf("hostName: %v\n", configPara.hostName) + fmt.Printf("serverPort: %v\n", configPara.serverPort) + fmt.Printf("usr: %v\n", configPara.user) + fmt.Printf("password: %v\n", configPara.password) + fmt.Printf("================================================\n") +} + func main() { + printAllArgs() taosDriverName := "taosSql" demodb := "demodb" demot := "demot" fmt.Printf("\n======== start demo test ========\n") + + url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/" // open connect to taos server - db, err := sql.Open(taosDriverName, "root:taosdata@/tcp(192.168.1.217:7100)/") + db, err := sql.Open(taosDriverName, url) if err != nil { log.Fatalf("Open database error: %s\n", err) } diff --git a/tests/gotest/case001/case001.sh b/tests/gotest/case001/case001.sh index 5a9034c4d18e257eaaf9324c570fbc17b01c548b..831e9f83ac482c0a2c668e2ad0d16c4bf59f19aa 100644 --- a/tests/gotest/case001/case001.sh +++ b/tests/gotest/case001/case001.sh @@ -1,10 +1,6 @@ #!/bin/bash -################################################## -# -# Do go test -# -################################################## +echo "==== start run cases001.go" set +e #set -x @@ -12,59 +8,14 @@ set +e script_dir="$(dirname $(readlink -f $0))" #echo "pwd: $script_dir, para0: $0" -execName=$0 -execName=`echo ${execName##*/}` -goName=`echo ${execName%.*}` - -###### step 1: start one taosd -scriptDir=$script_dir/../../script/sh -bash $scriptDir/stop_dnodes.sh -bash $scriptDir/deploy.sh -n dnode1 -i 1 -bash $scriptDir/cfg.sh -n dnode1 -c walLevel -v 0 -bash $scriptDir/exec.sh -n dnode1 -s start - -###### step 2: set config item -TAOS_CFG=/etc/taos/taos.cfg -HOSTNAME=`hostname -f` - -if [ ! -f ${TAOS_CFG} ]; then - touch -f $TAOS_CFG -fi - -echo " " > $TAOS_CFG -echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG -echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG -echo "serverPort 7100" >> $TAOS_CFG -#echo "dataDir $DATA_DIR" >> $TAOS_CFG -#echo "logDir $LOG_DIR" >> $TAOS_CFG -#echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG -echo "numOfLogLines 100000000" >> $TAOS_CFG -echo "dDebugFlag 135" >> $TAOS_CFG -echo "mDebugFlag 135" >> $TAOS_CFG -echo "sdbDebugFlag 135" >> $TAOS_CFG -echo "rpcDebugFlag 135" >> $TAOS_CFG -echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 135" >> $TAOS_CFG -echo "monitorDebugFlag 135" >> $TAOS_CFG -echo "udebugFlag 135" >> $TAOS_CFG -echo "tablemetakeeptimer 5" >> $TAOS_CFG -echo "wal 0" >> $TAOS_CFG -echo "asyncLog 0" >> $TAOS_CFG -echo "locale en_US.UTF-8" >> $TAOS_CFG -echo "enableCoreFile 1" >> $TAOS_CFG -echo " " >> $TAOS_CFG - -ulimit -n 600000 -ulimit -c unlimited -# -##sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e -# +#execName=$0 +#execName=`echo ${execName##*/}` +#goName=`echo ${execName%.*}` ###### step 3: start build cd $script_dir rm -f go.* -go mod init $goName +go mod init demotest go build -sleep 1s -sudo ./$goName +sleep 1s +./demotest -h $1 -p $2