未验证 提交 43cb889a 编写于 作者: X xiaolei li 提交者: GitHub

test(driver): TypeScript RESTful publish and add package test to CI (#11417)

* test(driver): TypeScript RESTful publish and add package test to CI

* test(driver): TypeScript RESTful publish and add package test to CI,fix some mistakes

* test:test TypeScript and fix ci

* test:test TypeScript REST and fix ci

* test:Typescript cases and fix ci
上级 0990972a
node_modules/
package-lock.json
test.js
\ No newline at end of file
{
"devDependencies": {
"@types/node": "^17.0.23",
"typescript": "^4.6.3"
},
"scripts": {
"test": "tsc test.ts && node test.js"
},
"dependencies": {
"td2.0-rest-connector": "^1.0.3"
}
}
import { options, connect } from 'td2.0-rest-connector'
options.path = '/rest/sqlt'
options.host = 'localhost'
const db = 'rest_ts_db';
const table = 'rest'
const createDB = `create database if not exists ${db} keep 3650`;
const dropDB = `drop database if exists ${db}`;
const createTB = `create table if not exists ${db}.${table}(ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(40),nchr nchar(40))`;
const addColumn = `alter table ${db}.${table} add column new_column nchar(40) `;
const dropColumn = `alter table ${db}.${table} drop column new_column`;
const insertSql = `insert into ${db}.${table} values('2022-03-30 18:30:51.567',1,2,3,4,'binary1','nchar1')` +
`('2022-03-30 18:30:51.568',5,6,7,8,'binary2','nchar2')` +
`('2022-03-30 18:30:51.569',9,0,1,2,'binary3','nchar3')`;
const querySql = `select * from ${db}.${table}`;
const errorSql = 'show database';
let conn = connect(options);
let cursor = conn.cursor();
async function execute(sql:string, pure = false) {
let result = await cursor.query(sql, pure);
// print query result as taos shell
result.toString();
// Get Result object, return Result object.
console.log("result.getResult()",result.getResult());
// Get status, return 'succ'|'error'.
console.log("result.getStatus()",result.getStatus());
// Get head,return response head (Array<any>|undefined,when execute failed this is undefined).
console.log("result.getHead()",result.getHead());
// Get Meta data, return Meta[]|undefined(when execute failed this is undefined).
console.log("result.getMeta()",result.getMeta());
// Get data,return Array<Array<any>>|undefined(when execute failed this is undefined).
console.log("result.getData()",result.getData());
// Get affect rows,return number|undefined(when execute failed this is undefined).
console.log("result.getAffectRows()",result.getAffectRows());
// Get command,return SQL send to server(need to `query(sql,false)`,set 'pure=false',default true).
console.log("result.getCommand()",result.getCommand());
// Get error code ,return number|undefined(when execute failed this is undefined).
console.log("result.getErrCode()",result.getErrCode());
// Get error string,return string|undefined(when execute failed this is undefined).
console.log("result.getErrStr()",result.getErrStr());
}
(async () => {
let start = new Date().getTime(); // 开始时间
await execute(createDB);
await execute(createTB);
await execute(addColumn);
await execute(dropColumn);
await execute(insertSql);
await execute(querySql);
await execute(errorSql);
await execute(dropDB);
let end = new Date().getTime(); // 结束时间
console.log("total spend time:%d ms",end - start);
})()
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
......@@ -4,3 +4,4 @@ dist/module
dist/types.d.ts
node_modules/
tsc/
.parcel-cache/
\ No newline at end of file
import { options, connect } from '../tdengine_rest'
options.path = '/rest/sqlt'
options.host = 'localhost'
const db = 'rest_ts_db';
const table = 'rest'
const createDB = `create database if not exists ${db} keep 3650`;
......
{
"name": "td2.0-rest-connector",
"version": "1.0.0",
"version": "1.0.3",
"description": "A REST connector for TDengine",
"source": "tdengine_rest.ts",
"main": "dist/main/rest.js",
......@@ -16,6 +16,11 @@
"build": "parcel build --no-source-maps",
"watch": "parcel watch"
},
"repository": {
"type": "git",
"url": "https://github.com/taosdata/TDengine/tree/develop/src/connector/TypeScript-REST"
},
"keywords": [
"REST",
"Node.js",
......@@ -25,17 +30,21 @@
"IOT",
"node-fetch"
],
"author": "",
"author": "TaosData Inc.",
"license": "MIT",
"dependencies": {
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.7",
"@types/node": "^17.0.23"
},
"devDependencies": {
"@parcel/packager-ts": "^2.4.1",
"@parcel/transformer-typescript-types": "^2.4.1",
"@types/node": "^17.0.23",
"@types/node-fetch": "^2.6.1",
"parcel": "^2.4.0",
"typescript": "^4.6.3"
}
},
"bugs": {
"url": "https://github.com/taosdata/tdengine/issues"
},
"homepage": "https://github.com/taosdata/tdengine#readme"
}
......@@ -4,12 +4,16 @@ This is a TDengine's RESTful connector in TypeScript. It's depend on [node-fetch
# Usage
```TypeScript
import { options, connect } from '../tdengine_rest'
import { options, connect } from 'td2.0-rest-connector'
options.path='/rest/sqlt';
// set host
options.host='localhost';
// set other options like user/passwd
let conn = connect(options);
let cursor = conn.cursor();
(async()=>{
let result = cursor.execute("show database");
let result = await cursor.query('show databases');
// print query result as taos shell
result.toString();
// Get Result object, return Result object.
......
......@@ -10,7 +10,7 @@ export interface User {
}
export interface Uri {
host: '127.0.0.1';
host: '127.0.0.1'|string;
path: "/rest/sqlt" | '/rest/sqlutc' | '/rest/sql';
port: 6041;
}
\ No newline at end of file
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# End of https://www.toptal.com/developers/gitignore/api/node
lib/
yarn.lock
import {TDengineRestConnection} from './src/restConnect'
export function TDRestConnection(connection = {}) {
return new TDengineRestConnection(connection)
}
import {TDengineRestConnection} from "../src/restConnect";
let conn = new TDengineRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041})
let cursor = conn.cursor();
console.log(conn)
let data = {};
(async () => {
data = await cursor.query("show databases");
data.toString()
})()
此差异已折叠。
{
"name": "td-rest-connector",
"version": "1.0.0",
"description": "A Node.js connector for TDengine restful",
"module": "src/TDengineRest.js",
"main": "lib/TDengineclearRest.js",
"license": "MIT",
"scripts": {
"prepare": "npm run build",
"build": "esbuild --bundle --platform=node --outfile=lib/TDengineRest.js ./TDengineRest.js",
"build:dev": "esbuild --bundle --platform=node --outfile=dist/examples/show-database.js examples/show-database.js ",
"build:test": "esbuild test/testRestConn.js --bundle --platform=node --outfile=dist/tests/testRestConn.js ",
"test": "node dist/tests/testRestConn.js"
},
"devDependencies": {
"esbuild": "^0.12.25",
"eslint": "^7.32.0",
"assert": "^2.0.0"
},
"dependencies": {
"node-fetch": "^3.x"
}
}
# TDengine Nodejs Restful
This is the Node.js library that lets you connect to [TDengine](https://www.github.com/taosdata/tdengine) though
restful. This restful can help you access the TDengine from different platform.
## Install
To get started, just type in the following to install the connector through [npm](https://www.npmjs.com/)
```cmd
npm install td-rest-connector
```
## Usage
### Connection
```javascript
import taoRest from 'TDengineRest'
var connRest = taoRest({host:'127.0.0.1',user:'root',pass:'taosdata',port:6041})
```
query
```javascript
(async()=>{
data = await connRest.query("show databases");
data.toString();
}
)()
```
## Example
An example of using the NodeJS Restful connector to create a table with weather data and create and execute queries can be found [here](https://github.com/taosdata/TDengine/tree/master/tests/examples/node-rest/show-database.js)
## Contributing to TDengine
Please follow the [contribution guidelines](https://github.com/taosdata/TDengine/blob/master/CONTRIBUTING.md) to contribute to the project.
## License
[GNU AGPL v3.0](http://www.gnu.org/licenses/agpl-3.0.html)
import {TDengineRestCursor} from '../src/restCursor'
/**
*this class collect basic information that can be used to build
* a restful connection.
*/
export class TDengineRestConnection {
/**
* constructor,give variables some default values
* @param options
* @returns {TDengineRestConnection}
*/
constructor(options) {
this.host = 'localhost'
this.port = '6041'
this.user = 'root'
this.pass = 'taosdata'
this.path = '/rest/sqlt/'
this._initConnection(options)
return this
}
/**
* used to init the connection info using the input options
* @param options
* @private
*/
_initConnection(options) {
if (options['host']) {
this.host = options['host']
}
if (options['port']) {
this.port = options['port']
}
if (options['user']) {
this.user = options['user']
}
if (options['pass']) {
this.pass = options['pass']
}
if (options['path']) {
this.path = options['path']
}
}
/**
* cursor will return an object of TDengineRestCursor, which can send restful(http) request and get
* the response from server.
* @returns {TDengineRestCursor}
*/
cursor() {
return new TDengineRestCursor(this)
}
}
/**
* indicate the every type's type code
* @type {{"0": string, "1": string, "2": string, "3": string, "4": string, "5": string, "6": string, "7": string, "8": string, "9": string, "10": string}}
*/
export const typeCodesToName = {
0: 'Null',
1: 'Boolean',
2: 'Tiny Int',
3: 'Small Int',
4: 'Int',
5: 'Big Int',
6: 'Float',
7: 'Double',
8: 'Binary',
9: 'Timestamp',
10: 'Nchar',
}
/**
* get the type of input typecode, in fact the response of restful will send every column's typecode
* @param typecode
* @returns {*}
*/
export function getTaoType(typecode) {
return typeCodesToName[typecode];
}
\ No newline at end of file
import fetch from 'node-fetch'
import {TDengineRestResultSet} from '../src/restResult'
/**
* this class is core of restful js connector
* this class resends http request to the TDengine server
* and receive the response.
*/
export class TDengineRestCursor {
/**
* constructor,used to get the connection info
* @param connection
*/
constructor(connection) {
this._connection = null;
this.data = [];
this.http = false
if (connection != null) {
this._connection = connection
} else {
throw new Error("A TDengineRestConnection object is required to be passed to the TDengineRestCursor")
}
}
/**
* used to build an url,like http://localhost:6041/rest/sql
* @returns {string}
* @private
*/
_apiUpl() {
return (this.http ? "https" : "http") + "://" + this._connection.host + ":" + this._connection.port + this._connection.path
}
/**
* used to make an authorization token
* @returns {string}
* @private
*/
_token() {
return 'Basic ' + Buffer.from(this._connection.user + ":" + this._connection.pass).toString('base64')
}
/**
* Used fetch to send http request, and return the response as an object of TDengineRestResultSet
* @param sql
* @returns {Promise<TDengineRestResultSet>}
*/
async query(sql) {
try {
let response = await fetch(this._apiUpl(), {
method: 'POST',
body: sql,
headers: {'Authorization': this._token()}
})
// if (response.status == 'succ') {
return await new TDengineRestResultSet(await response.json())
// } else {
// throw new Error(response.desc)
// }
} catch (e) {
console.log("Request Failed " + e)
}
}
}
import {getTaoType} from '../src/restConstant'
export class TDengineRestResultSet {
constructor(result) {
this.status = '' //succ
this.column_name = {} //head
this.column_type = {} //column_meta
this.data = {}
this.affectRows = null //rows
this.code = null
this.desc = null
this._init(result)
}
//initial the resultSet with a jason parameter
/**
*
* @param jason
*/
_init(result) {
if (result.status) {
this.status = result.status
}
if (result.head) {
this.column_name = result.head
}
if (result.column_meta) {
this.column_type = result.column_meta
}
if (result.data) {
this.data = result.data
}
if (result.rows) {
this.affectRows = result.rows
}
if (result.code) {
this.code = result.code
}
if (result.desc) {
this.desc = result.desc
}
}
getStatus() {
return this.status
}
getColumn_name() {
return this.column_name
}
getColumn_type() {
let column_data = []
this.column_type.forEach(function (column) {
column[1] = getTaoType(column[1])
column_data.push(column)
})
return column_data
}
getData() {
return this.data
}
getAffectRow() {
return this.affectRows
}
getCode() {
return this.code
}
getDesc() {
return this.desc
}
toString() {
if(this.status === 'succ'){
let fields = this.column_type
let rows = this.data
this._prettyStr(fields, rows)
}else{
console.log(this.status+":"+this.desc)
}
}
_prettyStr(fields, data) {
let colName = []
let colType = []
let colSize = []
let colStr = ""
for (let i = 0; i < fields.length; i++) {
colName.push(fields[i][0])
colType.push(fields[i][1])
if ((fields[i][1]) == 8 || (fields[i][1]) == 10) {
colSize.push(Math.max(fields[i][0].length, fields[i][2])); //max(column_name.length,column_type_precision)
} else {
colSize.push(Math.max(fields[i][0].length, suggestedMinWidths[fields[i][1]]));// max(column_name.length,suggest_column_with_suggestion)
}
// console.log(colSize)
}
colName.forEach((name, i) => {
colStr += this._fillEmpty(Math.floor(colSize[i] / 2 - name.length / 2)) + name.toString() + this._fillEmpty(Math.ceil(colSize[i] / 2 - name.length / 2)) + " | "
})
let strSperator = ""
let sizeSum = colSize.reduce((a, b) => a += b, (0)) + colSize.length * 3
strSperator = this._printN("=", sizeSum)
console.log("\n" + colStr)
console.log(strSperator)
data.forEach((row) => {
let rowStr = ""
row.forEach((cell, index) => {
rowStr += cell == null ? 'null' : cell.toString();
rowStr += this._fillEmpty(colSize[index] - cell.toString().length) + " | "
})
console.log(rowStr)
})
return colStr
}
_fillEmpty(n) {
let str = "";
for (let i = 0; i < n; i++) {
str += " ";
}
return str;
}
_printN(s, n) {
let f = "";
for (let i = 0; i < n; i++) {
f += s;
}
return f;
}
}
const suggestedMinWidths = {
0: 4,
1: 4,
2: 4,
3: 6,
4: 11,
5: 12,
6: 24,
7: 24,
8: 10,
9: 25,
10: 10,
}
import {TDRestConnection} from "../TDengineRest";
import assert from "assert"
let conn = new TDRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041});
let cursor = conn.cursor();
const createDB = "create database if not exists node_rest";
const dropDB = "drop database if exists node_rest";
const createTBL = "CREATE STABLE if not exists node_rest.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)";
const dropTBL = "drop table if exists node_rest.meters ";
const insert = "INSERT INTO node_rest.d1001 USING node_rest.meters TAGS (\"Beijng.Chaoyang\", 2) VALUES (now, 10.2, 219, 0.32) ";
const select = "select * from node_rest.d1001 ";
const selectStbl = "select * from node_rest.meters";
async function execute(sql) {
console.log("SQL:" + sql);
let result = await cursor.query(sql);
try {
assert.strictEqual(result.getStatus(), 'succ', new Error("response error"))
result.toString()
} catch (e) {
console.log(e)
}
}
(async () => {
await execute(createDB);
await execute(createTBL);
await execute(insert);
await execute(select);
await execute(selectStbl);
await execute(dropDB);
})()
// (async () => {
// result = await cursor.query("drop database if exists node_rest").catch(e=>console.log(e))
// result.toString()
// })()
......@@ -17,8 +17,8 @@ stopProcess taosd
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
nohup taosd -c ${taosdConfig} > /dev/null 2>&1 &
nohup taosadapter -c ${adapterConfig} > /dev/null 2>&1 &
nohup taosd > /dev/null 2>&1 &
nohup taosadapter > /dev/null 2>&1 &
sleep 10
# echo `pwd`
......@@ -27,9 +27,14 @@ WKC=`pwd`
echo ${WKC}
cd ${WKC}/src/connector/TypeScript-REST
# test source code
npm install
npm run example
# npm run test
# test published npm package td2.0-rest-connecto
cd ${WKC}/tests/examples/TypeScript-REST
npm install
npm run test
......@@ -235,6 +235,7 @@
30,,script,./test.sh -f general/import/commit.sim
30,,script,./test.sh -f general/compute/diff2.sim
30,,develop-test,bash 3-connectors/R/test.sh
30,,develop-test,bash 3-connectors/TypeScript-REST/test.sh
29,,system-test,python3 ./test.py -f 0-others/create_col_tag.py
29,,script,./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
29,,script,./test.sh -f general/wal/maxtables.sim
......@@ -311,7 +312,6 @@
20,,develop-test,python3 test.py -f 2-query/ltrim_func.py
20,,develop-test,python3 test.py -f 2-query/rtrim_func.py
20,,develop-test,python3 test.py -f 2-query/substr_func.py
20,,develop-test,bash 3-connectors/TypeScript-REST/test.sh
20,,pytest,python3 test.py -f query/query.py
20,,pytest,python3 test.py -f import_merge/importLastTO.py
20,,pytest,python3 test.py -f import_merge/importDataSub.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册