Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30317-3.0
This commit is contained in:
commit
f85a4df0e6
|
@ -47,7 +47,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item);
|
|||
/**
|
||||
* @brief API PRIVATE Pop the first item off of the list
|
||||
*/
|
||||
void *taos_linked_list_pop(taos_linked_list_t *self);
|
||||
//void *taos_linked_list_pop(taos_linked_list_t *self);
|
||||
|
||||
/**
|
||||
* @brief API PRIVATE Returns the item at the head of the list or NULL if not present
|
||||
|
|
|
@ -33,6 +33,8 @@ taos_map_t *taos_collector_default_collect(taos_collector_t *self) { return self
|
|||
taos_collector_t *taos_collector_new(const char *name) {
|
||||
int r = 0;
|
||||
taos_collector_t *self = (taos_collector_t *)taos_malloc(sizeof(taos_collector_t));
|
||||
if (self == NULL) return NULL;
|
||||
memset(self, 0, sizeof(taos_collector_t));
|
||||
self->name = taos_strdup(name);
|
||||
self->metrics = taos_map_new();
|
||||
if (self->metrics == NULL) {
|
||||
|
@ -66,9 +68,11 @@ int taos_collector_destroy(taos_collector_t *self) {
|
|||
if (r) ret = r;
|
||||
self->metrics = NULL;
|
||||
|
||||
r = taos_string_builder_destroy(self->string_builder);
|
||||
if (r) ret = r;
|
||||
self->string_builder = NULL;
|
||||
if(self->string_builder != NULL){
|
||||
r = taos_string_builder_destroy(self->string_builder);
|
||||
if (r) ret = r;
|
||||
self->string_builder = NULL;
|
||||
}
|
||||
|
||||
taos_free((char *)self->name);
|
||||
self->name = NULL;
|
||||
|
|
|
@ -59,6 +59,7 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) {
|
|||
r = pthread_rwlock_init(self->lock, NULL);
|
||||
if (r) {
|
||||
TAOS_LOG("failed to initialize rwlock");
|
||||
taos_free(self);
|
||||
return NULL;
|
||||
}
|
||||
return self;
|
||||
|
@ -301,6 +302,9 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
|
|||
|
||||
_OVER:
|
||||
tjsonDelete(pJson);
|
||||
if(tmp_builder != NULL){
|
||||
taos_string_builder_destroy(tmp_builder);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
void *taos_linked_list_pop(taos_linked_list_t *self) {
|
||||
TAOS_ASSERT(self != NULL);
|
||||
if (self == NULL) return NULL;
|
||||
|
@ -141,6 +142,7 @@ void *taos_linked_list_pop(taos_linked_list_t *self) {
|
|||
}
|
||||
return item;
|
||||
}
|
||||
*/
|
||||
|
||||
int taos_linked_list_remove(taos_linked_list_t *self, void *item) {
|
||||
TAOS_ASSERT(self != NULL);
|
||||
|
|
|
@ -90,7 +90,7 @@ taos_map_t *taos_map_new() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
self->addrs = taos_malloc(sizeof(taos_linked_list_t) * self->max_size);
|
||||
self->addrs = taos_malloc(sizeof(taos_linked_list_t*) * self->max_size);
|
||||
self->free_value_fn = destroy_map_node_value_no_op;
|
||||
|
||||
for (int i = 0; i < self->max_size; i++) {
|
||||
|
@ -273,7 +273,7 @@ int taos_map_ensure_space(taos_map_t *self) {
|
|||
if (r) return r;
|
||||
|
||||
// Create a new array of addrs
|
||||
taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t) * new_max);
|
||||
taos_linked_list_t **new_addrs = taos_malloc(sizeof(taos_linked_list_t*) * new_max);
|
||||
|
||||
// Initialize the new array
|
||||
for (int i = 0; i < new_max; i++) {
|
||||
|
|
|
@ -33,6 +33,8 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
|
|||
size_t label_key_count, const char **label_keys) {
|
||||
int r = 0;
|
||||
taos_metric_t *self = (taos_metric_t *)taos_malloc(sizeof(taos_metric_t));
|
||||
if (self == NULL) return NULL;
|
||||
memset(self, 0, sizeof(taos_metric_t));
|
||||
self->type = metric_type;
|
||||
int len = strlen(name) + 1;
|
||||
self->name = taos_malloc(len);
|
||||
|
@ -79,6 +81,7 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
|
|||
r = pthread_rwlock_init(self->rwlock, NULL);
|
||||
if (r) {
|
||||
TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR);
|
||||
taos_free(self);
|
||||
return NULL;
|
||||
}
|
||||
return self;
|
||||
|
@ -91,9 +94,11 @@ int taos_metric_destroy(taos_metric_t *self) {
|
|||
int r = 0;
|
||||
int ret = 0;
|
||||
|
||||
r = taos_map_destroy(self->samples);
|
||||
self->samples = NULL;
|
||||
if (r) ret = r;
|
||||
if(self->samples != NULL){
|
||||
r = taos_map_destroy(self->samples);
|
||||
self->samples = NULL;
|
||||
if (r) ret = r;
|
||||
}
|
||||
|
||||
r = taos_metric_formatter_destroy(self->formatter);
|
||||
self->formatter = NULL;
|
||||
|
@ -152,8 +157,7 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const
|
|||
return NULL;
|
||||
|
||||
// Get l_value
|
||||
r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys,
|
||||
label_values);
|
||||
r = taos_metric_formatter_load_l_value(self->formatter, self->name, NULL, self->label_key_count, self->label_keys, label_values);
|
||||
if (r) {
|
||||
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
||||
}
|
||||
|
@ -170,10 +174,12 @@ taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const
|
|||
sample = taos_metric_sample_new(self->type, l_value, 0.0);
|
||||
r = taos_map_set(self->samples, l_value, sample);
|
||||
if (r) {
|
||||
taos_free((void *)l_value);
|
||||
TAOS_METRIC_SAMPLE_FROM_LABELS_HANDLE_UNLOCK();
|
||||
}
|
||||
}
|
||||
pthread_rwlock_unlock(self->rwlock);
|
||||
r = pthread_rwlock_unlock(self->rwlock);
|
||||
if (r) TAOS_LOG(TAOS_PTHREAD_RWLOCK_UNLOCK_ERROR);
|
||||
taos_free((void *)l_value);
|
||||
return sample;
|
||||
}
|
||||
|
|
|
@ -798,6 +798,7 @@ TEST(queryTest, normalCase) {
|
|||
|
||||
schedulerFreeJob(&job, 0);
|
||||
|
||||
taosThreadJoin(thread1, NULL);
|
||||
}
|
||||
|
||||
TEST(queryTest, readyFirstCase) {
|
||||
|
@ -907,6 +908,8 @@ TEST(queryTest, readyFirstCase) {
|
|||
schedulerDestroy();
|
||||
|
||||
schedulerFreeJob(&job, 0);
|
||||
|
||||
taosThreadJoin(thread1, NULL);
|
||||
}
|
||||
|
||||
TEST(queryTest, flowCtrlCase) {
|
||||
|
@ -1001,6 +1004,8 @@ TEST(queryTest, flowCtrlCase) {
|
|||
schedulerDestroy();
|
||||
|
||||
schedulerFreeJob(&job, 0);
|
||||
|
||||
taosThreadJoin(thread1, NULL);
|
||||
}
|
||||
|
||||
TEST(insertTest, normalCase) {
|
||||
|
@ -1061,6 +1066,8 @@ TEST(insertTest, normalCase) {
|
|||
schedulerFreeJob(&insertJobRefId, 0);
|
||||
|
||||
schedulerDestroy();
|
||||
|
||||
taosThreadJoin(thread1, NULL);
|
||||
}
|
||||
|
||||
TEST(multiThread, forceFree) {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
###################################################################
|
||||
# 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 time
|
||||
|
||||
import taos
|
||||
import frame
|
||||
import frame.etool
|
||||
|
||||
from frame.log import *
|
||||
from frame.cases import *
|
||||
from frame.sql import *
|
||||
from frame.caseBase import *
|
||||
from frame import *
|
||||
|
||||
|
||||
class TDTestCase(TBase):
|
||||
def alterSupportVnodes(self):
|
||||
tdLog.info(f"test function of altering supportVnodes")
|
||||
|
||||
tdSql.execute("alter dnode 1 'supportVnodes' '128'")
|
||||
time.sleep(1)
|
||||
tdSql.query('show dnodes')
|
||||
tdSql.checkData(0, 3, "128")
|
||||
|
||||
tdSql.execute("alter dnode 1 'supportVnodes' '64'")
|
||||
time.sleep(1)
|
||||
tdSql.query('show dnodes')
|
||||
tdSql.checkData(0, 3, "64")
|
||||
|
||||
# run
|
||||
def run(self):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
|
||||
# TS-4721
|
||||
self.alterSupportVnodes()
|
||||
|
||||
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,63 @@
|
|||
import taos
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import glob
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from frame.log import *
|
||||
from frame.cases import *
|
||||
from frame.sql import *
|
||||
from frame.srvCtl import *
|
||||
from frame.caseBase import *
|
||||
from frame import *
|
||||
from frame.autogen import *
|
||||
# from frame.server.dnodes import *
|
||||
# from frame.server.cluster import *
|
||||
|
||||
|
||||
class TDTestCase(TBase):
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
super(TDTestCase, self).init(conn, logSql, replicaVar=1, checkColName="c1")
|
||||
self.valgrind = 0
|
||||
self.db = "test"
|
||||
self.stb = "meters"
|
||||
self.childtable_count = 10
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def create_encrypt_db(self):
|
||||
|
||||
tdSql.execute("create encrypt_key '1234567890'")
|
||||
autoGen = AutoGen()
|
||||
autoGen.create_db(self.db, 2, 1, "ENCRYPT_ALGORITHM 'sm4'")
|
||||
tdSql.execute(f"use {self.db}")
|
||||
autoGen.create_stable(self.stb, 2, 3, 8, 8)
|
||||
autoGen.create_child(self.stb, "d", self.childtable_count)
|
||||
autoGen.insert_data(1000)
|
||||
|
||||
tdSql.query(f"select * from {self.db}.{self.stb}")
|
||||
tdSql.checkRows(1000 * self.childtable_count)
|
||||
|
||||
self.timestamp_step = 1000
|
||||
self.insert_rows = 1000
|
||||
|
||||
self.checkInsertCorrect()
|
||||
|
||||
def create_encrypt_db_error(self):
|
||||
tdSql.error("create encrypt_key '123'")
|
||||
tdSql.error("create encrypt_key '12345678abcdefghi'")
|
||||
tdSql.error("create database test ENCRYPT_ALGORITHM 'sm4'")
|
||||
|
||||
def run(self):
|
||||
self.create_encrypt_db_error()
|
||||
self.create_encrypt_db()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -11,6 +11,7 @@
|
|||
# army-test
|
||||
#
|
||||
,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2
|
||||
,,y,army,./pytest.sh python3 ./test.py -f enterprise/db-encrypt/basic.py
|
||||
,,n,army,python3 ./test.py -f enterprise/s3/s3Basic.py -N 3
|
||||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
|
||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
||||
|
@ -25,6 +26,7 @@
|
|||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/splitVgroupByLearner.py -N 3
|
||||
,,n,army,python3 ./test.py -f community/cmdline/fullopt.py
|
||||
,,n,army,python3 ./test.py -f community/query/show.py -N 3
|
||||
,,n,army,python3 ./test.py -f enterprise/alter/alterConfig.py -N 3
|
||||
,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1
|
||||
,,y,army,./pytest.sh python3 ./test.py -f community/storage/compressBasic.py -N 3
|
||||
|
||||
|
|
|
@ -15,6 +15,30 @@ class TDTestCase:
|
|||
#tdSql.init(conn.cursor())
|
||||
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||
|
||||
def interp_on_empty_table(self):
|
||||
dbname = "db"
|
||||
tbname = "t"
|
||||
|
||||
tdSql.prepare()
|
||||
|
||||
tdLog.printNoPrefix("==========step1:create table")
|
||||
|
||||
tdSql.execute(f'''create table if not exists {dbname}.{tbname} (ts timestamp, k int)''')
|
||||
|
||||
tdLog.printNoPrefix("==========step2:interp query on empty table")
|
||||
|
||||
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(prev)")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(next)")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(linear)")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query(f"select _irowts, interp(k),k from {dbname}.{tbname} partition by k range(now()-1h, now()) every(1m) fill(value, 2)")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
def run(self):
|
||||
dbname = "db"
|
||||
tbname = "tb"
|
||||
|
@ -5658,6 +5682,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, '2023-08-06 23:59:00')
|
||||
tdSql.checkData(0, 1, None)
|
||||
|
||||
self.interp_on_empty_table()
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
|
Loading…
Reference in New Issue