metaTests.cpp 1.1 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1
#include <gtest/gtest.h>
H
Hongze Cheng 已提交
2
#include <string.h>
H
refact  
Hongze Cheng 已提交
3 4 5 6
#include <iostream>

#include "meta.h"

H
more  
Hongze Cheng 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20
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;
}

H
more  
Hongze Cheng 已提交
21
TEST(MetaTest, meta_create_1m_normal_tables_test) {
H
Hongze Cheng 已提交
22
  // Open Meta
H
Hongze Cheng 已提交
23 24 25
  SMeta *meta = metaOpen(NULL);
  std::cout << "Meta is opened!" << std::endl;

H
more  
Hongze Cheng 已提交
26 27 28 29
  // Create 1000000 normal tables
  META_TABLE_OPTS_DECLARE(tbOpts)
  STSchema *pSchema = metaGetSimpleSchema();
  char      tbname[128];
H
Hongze Cheng 已提交
30

H
more  
Hongze Cheng 已提交
31 32 33
  for (size_t i = 0; i < 1000000; i++) {
    sprintf(tbname, "ntb%ld", i);
    metaNormalTableOptsInit(&tbOpts, tbname, pSchema);
H
more  
Hongze Cheng 已提交
34
    metaCreateTable(meta, &tbOpts);
H
more  
Hongze Cheng 已提交
35
    metaTableOptsDestroy(&tbOpts);
H
more  
Hongze Cheng 已提交
36
  }
H
Hongze Cheng 已提交
37 38

  // Close Meta
H
Hongze Cheng 已提交
39 40
  metaClose(meta);
  std::cout << "Meta is closed!" << std::endl;
H
more  
Hongze Cheng 已提交
41

H
more  
Hongze Cheng 已提交
42 43 44
  // Destroy Meta
  metaDestroy("meta");
  std::cout << "Meta is destroyed!" << std::endl;
H
refact  
Hongze Cheng 已提交
45
}