未验证 提交 27c60f17 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

chore: add taosws-rs as plugin (#14548)

* chore: add taosws-rs as plugin

* chore: update taosws-rs

* chore: add taosws install/remove in scripts

* chore: update taosws-rs

* chore: update taosws-rs

* fix: _smartly_ build ws lib

* chore: enhance CMakeLists.txt

* fix: packaging/tools/make_install.sh

* chore: update taos-tools

* docs: modify readme

* fix: tools/*.sh
上级 79d62658
......@@ -22,3 +22,6 @@
[submodule "src/connector/php-tdengine-restful-connector"]
path = src/connector/php-tdengine-restful-connector
url = https://github.com/Yurunsoft/tdengine-restful-connector.git
[submodule "src/plugins/taosws-rs"]
path = src/plugins/taosws-rs
url = https://github.com/taosdata/taosws-rs
......@@ -53,7 +53,7 @@ TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后
### Ubuntu 16.04 及以上版本 & Debian:
```bash
sudo apt-get install -y gcc cmake build-essential git
sudo apt-get install -y gcc cmake build-essential git libssl-dev
```
### Ubuntu 14.04:
......@@ -86,13 +86,13 @@ taosTools 是用于 TDengine 的辅助工具软件集合。目前它包含 taosB
为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件:
```bash
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config libssl-dev
```
### CentOS 7
### CentOS 7/RHEL
```bash
sudo yum install -y gcc gcc-c++ make cmake git
sudo yum install -y gcc gcc-c++ make cmake git openssl-devel
```
安装 OpenJDK 8:
......@@ -107,10 +107,10 @@ sudo yum install -y java-1.8.0-openjdk
sudo yum install -y maven
```
### CentOS 8 & Fedora
### CentOS 8/Fedora/Rocky Linux
```bash
sudo dnf install -y gcc gcc-c++ make cmake epel-release git
sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
```
安装 OpenJDK 8:
......@@ -130,13 +130,28 @@ sudo dnf install -y maven
为了在 CentOS 上构建 [taosTools](https://github.com/taosdata/taos-tools) 需要安装如下依赖软件
```bash
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
```
注意:由于 snappy 缺乏 pkg-config 支持
(参考 [链接](https://github.com/google/snappy/pull/86)),会导致
cmake 提示无法发现 libsnappy,实际上工作正常。
### 设置 golang 开发环境
TDengine 包含数个使用 Go 语言开发的组件,请参考 golang.org 官方文档设置 go 开发环境。
请使用 1.14 及以上版本。对于中国用户,我们建议使用代理来加速软件包下载。
```
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
```
### 设置 rust 开发环境
TDengine 包含数个使用 Rust 语言开发的组件. 请参考 rust-lang.org 官方文档设置 rust 开发环境。
## 获取源码
首先,你需要从 GitHub 克隆源码:
......
......@@ -56,7 +56,7 @@ To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in t
### Ubuntu 16.04 and above or Debian
```bash
sudo apt-get install -y gcc cmake build-essential git
sudo apt-get install -y gcc cmake build-essential git libssl-dev
```
### Ubuntu 14.04
......@@ -88,15 +88,15 @@ By default, TDengine compiling does not include taosTools. You can use 'cmake ..
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
```bash
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config libssl-dev
```
### CentOS 7
### CentOS 7/RHEL
```bash
sudo yum install epel-release
sudo yum update
sudo yum install -y gcc gcc-c++ make cmake3 git
sudo yum install -y gcc gcc-c++ make cmake3 git openssl-devel
sudo ln -sf /usr/bin/cmake3 /usr/bin/cmake
```
......@@ -112,10 +112,10 @@ To install Apache Maven:
sudo yum install -y maven
```
### CentOS 8 & Fedora
### CentOS 8/Fedora/Rocky Linux
```bash
sudo dnf install -y gcc gcc-c++ make cmake epel-release git
sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
```
To install openjdk-8:
......@@ -135,7 +135,7 @@ sudo dnf install -y maven
To build the [taosTools](https://github.com/taosdata/taos-tools) on CentOS, the following packages need to be installed.
```bash
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
```
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it lead a cmake prompt libsnappy not found. But snappy will works well.
......@@ -151,6 +151,10 @@ go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
```
### Setup rust environment
TDengine includees few compoments developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup.
## Get the source codes
First of all, you may clone the source codes from github:
......
......@@ -112,6 +112,10 @@ IF (TD_ALPINE)
MESSAGE(STATUS "alpine is defined")
ENDIF ()
IF ("${WEBSOCKET}" MATCHES "true")
SET(TD_WEBSOCKET TRUE)
ENDIF ()
IF ("${BUILD_HTTP}" STREQUAL "")
IF (TD_LINUX)
IF (TD_ARM_32)
......@@ -169,6 +173,11 @@ IF (${BUILD_LUA} MATCHES "false")
SET(TD_BUILD_LUA FALSE)
ENDIF ()
IF (TD_WEBSOCKET)
MESSAGE("Enable websocket")
ADD_DEFINITIONS(-DWEBSOCKET)
ENDIF()
IF (TD_BUILD_LUA)
MESSAGE("Enable lua")
ADD_DEFINITIONS(-DLUA_EMBEDDED)
......
......@@ -76,6 +76,8 @@ ENDIF ()
SET(TD_BUILD_HTTP TRUE)
SET(TD_WEBSOCKET FALSE)
SET(TD_TAOS_TOOLS TRUE)
SET(TD_BUILD_LUA TRUE)
......
......@@ -37,4 +37,5 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then
fi
# there can not libtaos.so*, otherwise ln -s error
${csudo}rm -f ${install_main_dir}/driver/libtaos* || :
${csudo}rm -f ${install_main_dir}/driver/libtaos.* || :
${csudo}rm -f ${install_main_dir}/driver/libtaosws.* || :
......@@ -29,7 +29,11 @@ else
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${cfg_link_dir}/* || :
${csudo}rm -f ${inc_link_dir}/taos.h || :
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
${csudo}rm -f ${inc_link_dir}/taosws.h || :
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
${csudo}rm -f ${log_link_dir} || :
${csudo}rm -f ${data_link_dir} || :
......
......@@ -30,6 +30,7 @@ mkdir -p ${pkg_dir}
cd ${pkg_dir}
libfile="libtaos.so.${tdengine_ver}"
wslibfile="libtaosws.so"
# create install dir
install_home_path="/usr/local/taos"
......@@ -67,9 +68,11 @@ fi
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||:
cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../src/inc/taosdef.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../src/inc/taoserror.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../src/inc/taosws.h ${pkg_dir}${install_home_path}/include ||:
cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples
#cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector
#cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector
......
......@@ -42,6 +42,7 @@ echo version: %{_version}
echo buildroot: %{buildroot}
libfile="libtaos.so.%{_version}"
wslibfile="libtaosws.so"
# create install path, and cp file
mkdir -p %{buildroot}%{homepath}/bin
......@@ -74,9 +75,11 @@ if [ -f %{_compiledir}/build/bin/taosadapter ]; then
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
fi
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||:
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taosdef.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taosws.h %{buildroot}%{homepath}/include ||:
#cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
#cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
#cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector
......
......@@ -229,9 +229,13 @@ function install_lib() {
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
${csudo}ln -s ${lib_link_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so || :
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
${csudo}ln -s ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
fi
${csudo}ldconfig
......@@ -315,10 +319,15 @@ function install_jemalloc() {
function install_header() {
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || :
${csudo}rm -f ${inc_link_dir}/taosws.h || :
${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
[ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || :
}
function add_newHostname_to_hosts() {
......
......@@ -291,14 +291,16 @@ function install_avro() {
function install_lib() {
# Remove links
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
if [ "$osType" != "Darwin" ]; then
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
fi
if [ "$osType" != "Darwin" ]; then
${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \
${install_main_dir}/driver &&
${csudo}chmod 777 ${install_main_dir}/driver/*
${csudo}chmod 777 ${install_main_dir}/driver/libtaos.so.${verNumber}
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
......@@ -307,6 +309,16 @@ function install_lib() {
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1
${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so
fi
if [ -f ${binary_dir}/build/lib/libtaosws.so ]; then
${csudo}cp ${binary_dir}/build/lib/libtaosws.so \
${install_main_dir}/driver &&
${csudo}chmod 777 ${install_main_dir}/driver/libtaosws.so
${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || :
if [ -d "${lib64_link_dir}" ]; then
${csudo}ln -sf ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || :
fi
fi
else
${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
${install_main_dir}/driver ||
......@@ -334,8 +346,8 @@ function install_lib() {
fi
install_jemalloc
install_avro lib
install_avro lib64
#install_avro lib
#install_avro lib64
if [ "$osType" != "Darwin" ]; then
${csudo}ldconfig
......@@ -346,11 +358,20 @@ function install_header() {
if [ "$osType" != "Darwin" ]; then
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || :
${csudo}rm -f ${inc_link_dir}/taosws.h || :
${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \
${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
if [ -f ${binary_dir}/build/include/taosws.h ]; then
${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h
${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||:
fi
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
else
${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \
${install_main_dir}/include ||
......
......@@ -161,13 +161,11 @@ if [[ $productName == "TDengine" ]]; then
mkdir -p ${install_dir}/connector
if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if [ "$osType" != "Darwin" ]; then
cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
fi
if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
cp -r ${connector_dir}/go ${install_dir}/connector
else
echo "WARNING: go connector not found, please check if want to use it!"
[ -f ${build_dir}/lib/*.jar ] && cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
fi
git clone --depth 1 https://github.com/taosdata/driver-go ${install_dir}/connector/go
rm -rf ${install_dir}/connector/go/.git ||:
git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python
rm -rf ${install_dir}/connector/python/.git ||:
# cp -r ${connector_dir}/python ${install_dir}/connector
......
......@@ -96,7 +96,10 @@ else
fi
lib_files="${build_dir}/lib/libtaos.so.${version}"
wslib_files="${build_dir}/lib/libtaosws.so."
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taosdef.h ${code_dir}/inc/taoserror.h"
wsheader_files="${code_dir}/inc/taosws.h"
if [ "$dbName" != "taos" ]; then
cfg_dir="${top_dir}/../enterprise/packaging/cfg"
......@@ -115,6 +118,9 @@ init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord
# make directories.
mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
[ -f ${wsheader_files} ] && cp ${wsheader_files} ${install_dir}/inc || :
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile}
# !!! do not change the taosadapter here!!!
......@@ -298,18 +304,17 @@ fi
# Copy driver
mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt
[ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver || :
# Copy connector
if [ "$verMode" == "cluster" ]; then
connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector
if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
cp -r ${connector_dir}/go ${install_dir}/connector
else
echo "WARNING: go connector not found, please check if want to use it!"
fi
[ -f ${build_dir}/lib/*.jar ] && cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
git clone --depth 1 https://github.com/taosdata/driver-go ${install_dir}/connector/go
rm -rf ${install_dir}/connector/go/.git ||:
git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python
rm -rf ${install_dir}/connector/python/.git ||:
......
......@@ -102,7 +102,10 @@ function clean_local_bin() {
function clean_lib() {
# Remove link
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
#${csudo}rm -rf ${v15_java_app_dir} || :
}
......@@ -111,6 +114,8 @@ function clean_header() {
${csudo}rm -f ${inc_link_dir}/taos.h || :
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
${csudo}rm -f ${inc_link_dir}/taosws.h || :
}
function clean_config() {
......
......@@ -11,17 +11,26 @@ IF (TD_LINUX)
LIST(REMOVE_ITEM SRC ./src/shellDarwin.c)
ADD_EXECUTABLE(shell ${SRC})
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
ELSE ()
SET(LINK_JEMALLOC "")
ENDIF ()
IF (TD_LINUX AND TD_WEBSOCKET)
ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws)
SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws")
ADD_DEPENDENCIES(shell taosws-rs)
ELSE ()
SET(LINK_WEBSOCKET "")
ENDIF ()
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
ADD_DEPENDENCIES(shell jemalloc)
ELSE ()
SET(LINK_JEMALLOC "")
ENDIF ()
IF (TD_SOMODE_STATIC)
TARGET_LINK_LIBRARIES(shell taos_static cJson ${LINK_LUA} ${LINK_JEMALLOC})
TARGET_LINK_LIBRARIES(shell taos_static cJson ${LINK_LUA} ${LINK_JEMALLOC} ${LINK_WEBSOCKET})
ELSE ()
TARGET_LINK_LIBRARIES(shell taos cJson ${LINK_LUA} ${LINK_JEMALLOC})
TARGET_LINK_LIBRARIES(shell taos cJson ${LINK_LUA} ${LINK_JEMALLOC} ${LINK_WEBSOCKET})
ENDIF ()
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
......@@ -32,7 +41,7 @@ ELSEIF (TD_WINDOWS)
LIST(APPEND SRC ./src/shellMain.c)
LIST(APPEND SRC ./src/shellWindows.c)
ADD_EXECUTABLE(shell ${SRC})
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
IF (JEMALLOC_ENABLED)
ADD_DEPENDENCIES(shell jemalloc)
ENDIF ()
......
Subproject commit 9cb71e3c4c0474553aa961cbe19795541c29b5c7
Subproject commit 3f42d428eb6b90dea2651f4ccea66e44705c831b
......@@ -3,6 +3,53 @@ PROJECT(TDengine)
ADD_SUBDIRECTORY(monitor)
IF (TD_WEBSOCKET)
MESSAGE("${Green} use libtaos-ws${ColourReset}")
IF (TD_LINUX)
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" OR
"${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/src/plugins/taosws-rs/FETCH_HEAD")
MESSAGE("target is newer than fetch head")
include(ExternalProject)
ExternalProject_Add(taosws-rs
PREFIX "taosws-rs"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
BUILD_ALWAYS off
DEPENDS taos
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND
COMMAND cargo build --release -p taos-ws-sys
COMMAND ./taos-ws-sys/ci/package.sh
INSTALL_COMMAND
COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
)
ELSE ()
include(ExternalProject)
ExternalProject_Add(taosws-rs
PREFIX "taosws-rs"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
BUILD_ALWAYS on
DEPENDS taos
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND
COMMAND cargo build --release -p taos-ws-sys
COMMAND ./taos-ws-sys/ci/package.sh
INSTALL_COMMAND
COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
)
ENDIF()
ENDIF()
ENDIF ()
IF (TD_BUILD_HTTP)
MESSAGE("")
MESSAGE("${Yellow} use original embedded httpd ${ColourReset}")
......
Subproject commit 7a94ffab45f08e16f09b3f430fe75d717054adb6
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1538548685000
self.numberOfTables = 10000
self.numberOfRecords = 100
def checkCommunity(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
return False
else:
return True
def getPath(self, tool="taosdump"):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
paths = []
for root, dirs, files in os.walk(projPath):
if ((tool) in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
paths.append(os.path.join(root, tool))
break
if (len(paths) == 0):
return ""
return paths[0]
def insert_data(self, tbname, ts_start, count):
pre_insert = "insert into %s values" % tbname
sql = pre_insert
tdLog.debug("doing insert table %s rows=%d ..." % (tbname, count))
for i in range(count):
sql += " (%d,%d)" % (ts_start + i * 1000, i)
if i > 0 and i % 30000 == 0:
tdSql.execute(sql)
sql = pre_insert
# end sql
if sql != pre_insert:
tdSql.execute(sql)
tdLog.debug("INSERT TABLE DATA ............ [OK]")
return
def run(self):
if not os.path.exists("./taosdumptest"):
os.makedirs("./taosdumptest")
else:
os.system("rm -rf ./taosdumptest")
os.makedirs("./taosdumptest")
for i in range(2):
if not os.path.exists("./taosdumptest/tmp%d" % i):
os.makedirs("./taosdumptest/tmp%d" % i)
else:
os.system("rm -rf ./taosdumptest/tmp%d" % i)
os.makedirs("./taosdumptest/tmp%d" % i)
binPath = self.getPath("taosdump")
if (binPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found: %s" % binPath)
# create db1 , one stables and one table ; create general tables
tdSql.execute("drop database if exists dp1")
tdSql.execute("drop database if exists dp2")
tdSql.execute("create database if not exists dp1")
tdSql.execute("use dp1")
tdSql.execute(
'''create table st0(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double,
c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp )
tags(t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(20), t9 nchar(20), t11 tinyint unsigned,
t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned, t15 timestamp)''')
tdSql.execute(
'''create table st1(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double,
c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) tags(jtag json)''')
intData = []
floatData = []
rowNum = 10
tabNum = 10
ts = 1537146000000
for j in range(tabNum):
tdSql.execute(
"create table st0_%d using st0 tags( %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d);" %
(j,
j +
1,
j +
1,
j +
1,
j +
1,
j +
0.1,
j +
0.1,
j %
2,
j +
1,
j +
1,
j +
1,
j +
1,
j +
1,
j +
1,
ts))
for i in range(rowNum):
tdSql.execute(
"insert into st0_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" %
(j, ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i %
2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, ts))
intData.append(i + 1)
floatData.append(i + 0.1)
rowNum = 20
tabNum = 20
for j in range(tabNum):
tdSql.execute(
"create table st1_%d using st1 tags('{\"nv\":null,\"tea\":true,\"\":false,\" \":123%d,\"tea\":false}');" %
(j, j + 1))
for i in range(rowNum):
tdSql.execute(
"insert into st1_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" %
(j, self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i %
2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts))
intData.append(i + 1)
floatData.append(i + 0.1)
# os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % benchBinPath)
# create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1
# \stb3,include ctables stb3_0 and stb3_1
# create general three tables gt0 gt1 gt2
tdSql.execute("create database if not exists dp2")
tdSql.execute("use dp2")
tdSql.execute(
"create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)")
tdSql.execute(
"create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ")
tdSql.execute(
"insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')")
tdSql.execute(
"insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')")
tdSql.execute(
"create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)")
tdSql.execute(
"create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ")
tdSql.execute(
"insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')")
tdSql.execute(
"insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')")
tdSql.execute(
"create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)")
tdSql.execute(
"create table st20 using st2 tags(0) st21 using st2 tags(1) ")
tdSql.execute(
"insert into st20 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')")
tdSql.execute(
"insert into st21 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')")
tdSql.execute(
"create table if not exists gt0 (ts timestamp, c00 int, c01 float) ")
tdSql.execute(
"create table if not exists gt1 (ts timestamp, c10 int, c11 double) ")
tdSql.execute(
"create table if not exists gt2 (ts timestamp, c20 int, c21 float) ")
tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)")
tdSql.execute(
"insert into gt1 values(1614218413800,8638,78.862020199)")
tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)")
# self.insert_data("t", self.ts, 300*10000);
# os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % benchBinPath)
# # taosdump data
# os.system("%s -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \
# -D dp1,dp3 -N -c /home/chr/TDinternal/community/sim/dnode1/cfg/taos.cfg -s -d deflate" % binPath)
os.system(
"%s -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" %
binPath)
os.system(
"%s -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" %
binPath)
# check taosdumptest/tmp0
tdSql.execute("drop database dp1")
tdSql.execute("drop database dp2")
os.system("%s -i ./taosdumptest/tmp0 -T 8 " % binPath)
tdSql.execute("reset query cache")
tdSql.execute("use dp1")
tdSql.query("show stables")
tdSql.checkRows(3)
for i in range(3):
for j in range(3):
if j < 2:
if tdSql.queryResult[i][0] == 'st%d' % j:
tdSql.checkData(i, 4, (j + 1) * 10)
else:
if tdSql.queryResult[i][0] == 'st%d' % j:
tdSql.checkData(i, 4, 100002)
tdSql.query("select count(*) from st0")
tdSql.checkData(0, 0, 100)
tdSql.query("select count(*) from st1")
tdSql.checkData(0, 0, 400)
tdSql.query("select count(*) from st2")
tdSql.checkData(0, 0, 1000020)
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(3)
for i in range(3):
for j in range(3):
if j < 2:
if tdSql.queryResult[i][0] == 'st%d' % j:
# print(i,"stb%d"%j)
tdSql.checkData(i, 4, 2)
else:
if tdSql.queryResult[i][0] == 'st%d' % j:
tdSql.checkData(i, 4, 100002)
tdSql.query("select count(*) from st0")
tdSql.checkData(0, 0, 4)
tdSql.query("select count(*) from st1")
tdSql.checkData(0, 0, 4)
tdSql.query("select count(*) from st2")
tdSql.checkData(0, 0, 1000024)
tdSql.query("select ts from gt0")
tdSql.checkData(0, 0, '2021-02-25 10:00:12.700')
tdSql.query("select c10 from gt1")
tdSql.checkData(0, 0, 8638)
tdSql.query("select c20 from gt2")
tdSql.checkData(0, 0, 8639)
# check taosdumptest/tmp1
tdSql.execute("drop database dp1")
tdSql.execute("drop database dp2")
os.system("%s -i ./taosdumptest/tmp1 -T 8 " % binPath)
tdSql.execute("reset query cache")
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(2)
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select count(*) from st1_0")
tdSql.checkData(0, 0, 2)
tdSql.query("select ts from gt0")
tdSql.checkData(0, 0, '2021-02-25 10:00:12.700')
tdSql.error("use dp1")
tdSql.error("select count(*) from st2_0")
tdSql.error("select count(*) from gt2")
# #check taosdumptest/tmp2
# tdSql.execute("drop database dp1")
# tdSql.execute("drop database dp2")
# os.system("%s -i ./taosdumptest/tmp2 -T 8 " % binPath)
# tdSql.execute("use dp1")
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(3)
# tdSql.query("select c1 from st0_0 order by ts")
# tdSql.checkData(0,0,8537)
# tdSql.query("select c2 from st0_1 order by ts")
# tdSql.checkData(1,0,"D")
# tdSql.query("select * from gt0")
# tdSql.checkData(0,0,'2021-02-25 10:00:12.000')
# tdSql.checkData(0,1,637)
# tdSql.error("select count(*) from gt1")
# tdSql.error("use dp2")
# #check taosdumptest/tmp3
# tdSql.execute("drop database dp1")
# os.system("%s -i ./taosdumptest/tmp3 -T 8 " % binPath)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(2)
# tdSql.query("show tables")
# tdSql.checkRows(4)
# tdSql.query("select count(*) from st1_0")
# tdSql.checkData(0,0,2)
# tdSql.query("select ts from gt0")
# tdSql.checkData(0,0,'2021-02-25 10:00:12.700')
# tdSql.error("use dp1")
# tdSql.error("select count(*) from st2_0")
# tdSql.error("select count(*) from gt2")
# #check taosdumptest/tmp4
# tdSql.execute("drop database dp2")
# os.system("%s -i ./taosdumptest/tmp4 -T 8 " % binPath)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(2)
# tdSql.query("show tables")
# tdSql.checkRows(6)
# tdSql.query("select c20 from gt2")
# tdSql.checkData(0, 0, 8639)
# tdSql.query("select count(*) from st0_0")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st0_1")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st2_1")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st2_0")
# tdSql.checkData(0, 0, 2)
# tdSql.error("use dp1")
# tdSql.error("select count(*) from st1_0")
# tdSql.error("select count(*) from st1_1")
# tdSql.error("select count(*) from gt3")
# #check taosdumptest/tmp5
# tdSql.execute("drop database dp2")
# os.system("%s -i ./taosdumptest/tmp5 -T 8 " % binPath)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(3)
# tdSql.query("show tables")
# tdSql.checkRows(9)
# tdSql.query("select c20 from gt2")
# tdSql.checkData(0, 0, 8639)
# tdSql.query("select count(*) from st0_0")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st0_1")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st2_1")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st2_0")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st1_1")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select count(*) from st1_0")
# tdSql.checkData(0, 0, 2)
# tdSql.execute("use dp1")
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(4)
# tdSql.query("select c1 from st0_0 order by ts")
# tdSql.checkData(0,0,8537)
# tdSql.query("select c2 from st0_1 order by ts")
# tdSql.checkData(1,0,"D")
# tdSql.query("select * from gt0")
# tdSql.checkData(0,0,'2021-02-25 10:00:12.000')
# tdSql.checkData(0,1,637)
# # check taosdumptest/tmp6
# tdSql.execute("drop database dp1")
# tdSql.execute("drop database dp2")
# tdSql.execute("drop database dp3")
# os.system("%s -i ./taosdumptest/tmp6 -T 8 " % binPath)
# tdSql.execute("use dp3")
# tdSql.query("show databases")
# tdSql.checkRows(1)
# tdSql.checkData(0,16,'ns')
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(1)
# tdSql.query("select count(*) from st0_0")
# tdSql.checkData(0, 0, 2)
# tdSql.query("select * from st0 order by ts")
# tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001')
# tdSql.checkData(0,1,8600)
# # check taosdumptest/tmp7
# tdSql.execute("drop database dp3")
# os.system("%s -i ./taosdumptest/tmp7 -T 8 " % binPath)
# tdSql.execute("use dp3")
# tdSql.query("show databases")
# tdSql.checkRows(1)
# tdSql.checkData(0,16,'ms')
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(1)
# tdSql.query("select count(*) from st0_0")
# tdSql.checkRows(0)
# # tdSql.query("select * from st0 order by ts")
# # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001')
# # tdSql.checkData(0,1,8600)
# # check taosdumptest/tmp8
# tdSql.execute("drop database dp3")
# os.system("%s -i ./taosdumptest/tmp8 -T 8 " % binPath)
# tdSql.execute("use dp3")
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(1)
# tdSql.query("select count(*) from st0_0")
# tdSql.checkRows(0)
# # tdSql.query("select * from st0 order by ts")
# # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001')
# # tdSql.checkData(0,1,8600)
# os.system("rm -rf ./taosdumptest/tmp1")
# os.system("rm -rf ./taosdumptest/tmp2")
# os.system("rm -rf ./taosdumptest/tmp3")
# os.system("rm -rf ./taosdumptest/tmp4")
# os.system("rm -rf ./taosdumptest/tmp5")
# os.system("rm -rf ./dump_result.txt")
# os.system("rm -rf ./db.csv")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册