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

37 lines
885 B
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"
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-12 07:11:44 +00:00
// Create tables
STableOpts tbOpts;
char tbname[128];
STSchema * pSchema;
STSchemaBuilder sb;
tdInitTSchemaBuilder(&sb, 0);
for (size_t i = 0; i < 10; i++) {
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, i, 8);
}
pSchema = tdGetSchemaFromBuilder(&sb);
tdDestroyTSchemaBuilder(&sb);
for (size_t i = 0; i < 1000000; i++) {
sprintf(tbname, "tb%ld", i);
metaTableOptsInit(&tbOpts, 0, tbname, pSchema);
metaCreateTable(meta, &tbOpts);
}
// 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-12 07:23:36 +00:00
// Destroy Meta
metaDestroy("meta");
std::cout << "Meta is destroyed!" << std::endl;
2021-10-11 07:41:49 +00:00
}