TDengine/source/server/vnode/meta/test/metaTests.cpp

45 lines
1.1 KiB
C++
Raw Normal View History

2021-10-11 07:41:49 +00:00
#include <gtest/gtest.h>
2021-10-12 07:11:44 +00:00
#include <string.h>
2021-10-11 07:41:49 +00:00
#include <iostream>
#include "meta.h"
2021-10-15 07:42:01 +00:00
static STSchema *metaGetSimpleSchema() {
STSchema * pSchema = NULL;
STSchemaBuilder sb;
tdInitTSchemaBuilder(&sb, 0);
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, 0, 8);
tdAddColToSchema(&sb, TSDB_DATA_TYPE_INT, 1, 4);
pSchema = tdGetSchemaFromBuilder(&sb);
tdDestroyTSchemaBuilder(&sb);
return pSchema;
}
2021-10-11 07:41:49 +00:00
TEST(MetaTest, meta_open_test) {
2021-10-12 07:11:44 +00:00
// Open Meta
2021-10-12 03:15:11 +00:00
SMeta *meta = metaOpen(NULL);
std::cout << "Meta is opened!" << std::endl;
2021-10-15 07:42:01 +00:00
// Create 1000000 normal tables
META_TABLE_OPTS_DECLARE(tbOpts)
STSchema *pSchema = metaGetSimpleSchema();
char tbname[128];
2021-10-12 07:11:44 +00:00
2021-10-15 07:42:01 +00:00
for (size_t i = 0; i < 1000000; i++) {
sprintf(tbname, "ntb%ld", i);
metaNormalTableOptsInit(&tbOpts, tbname, pSchema);
2021-10-15 07:13:46 +00:00
metaCreateTable(meta, &tbOpts);
2021-10-15 07:42:01 +00:00
metaTableOptsDestroy(&tbOpts);
2021-10-15 07:13:46 +00:00
}
2021-10-12 07:11:44 +00:00
// Close Meta
2021-10-12 03:15:11 +00:00
metaClose(meta);
std::cout << "Meta is closed!" << std::endl;
2021-10-12 03:41:27 +00:00
2021-10-15 06:59:35 +00:00
// // Destroy Meta
// metaDestroy("meta");
// std::cout << "Meta is destroyed!" << std::endl;
2021-10-11 07:41:49 +00:00
}