YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/tablet-test-util.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
#ifndef YB_TABLET_TABLET_TEST_UTIL_H
33
#define YB_TABLET_TABLET_TEST_UTIL_H
34
35
#include <memory>
36
#include <string>
37
#include <vector>
38
39
#include "yb/docdb/docdb_fwd.h"
40
41
#include "yb/tablet/tablet-harness.h"
42
43
#include "yb/util/test_util.h"
44
45
namespace yb {
46
47
class FsManager;
48
49
namespace docdb {
50
class DocRowwiseIterator;
51
}
52
53
namespace server {
54
class Clock;
55
}
56
57
namespace tablet {
58
59
class YBTabletTest : public YBTest {
60
 public:
61
  explicit YBTabletTest(const Schema& schema, TableType table_type = TableType::YQL_TABLE_TYPE);
62
63
  void SetUp() override;
64
65
  void CreateTestTablet(const std::string& root_dir = "");
66
67
  void SetUpTestTablet(const std::string& root_dir = "");
68
69
0
  void TabletReOpen(const std::string& root_dir = "") {
70
0
    SetUpTestTablet(root_dir);
71
0
  }
72
73
0
  const Schema &schema() const {
74
0
    return schema_;
75
0
  }
76
77
0
  const Schema &client_schema() const {
78
0
    return client_schema_;
79
0
  }
80
81
8
  server::Clock* clock() {
82
8
    return harness_->clock();
83
8
  }
84
85
20
  FsManager* fs_manager() {
86
20
    return harness_->fs_manager();
87
20
  }
88
89
  void AlterSchema(const Schema& schema);
90
91
2.66k
  const TabletPtr& tablet() const {
92
2.66k
    return harness_->tablet();
93
2.66k
  }
94
95
  TabletHarness* harness() {
96
    return harness_.get();
97
  }
98
99
 protected:
100
  const Schema schema_;
101
  const Schema client_schema_;
102
  TableType table_type_;
103
104
  std::unique_ptr<TabletHarness> harness_;
105
};
106
107
CHECKED_STATUS IterateToStringList(
108
    docdb::YQLRowwiseIteratorIf* iter, std::vector<std::string>* out, int limit = INT_MAX);
109
110
// Dump all of the rows of the tablet into the given vector.
111
CHECKED_STATUS DumpTablet(
112
    const Tablet& tablet, const Schema& projection, std::vector<std::string>* out);
113
114
} // namespace tablet
115
} // namespace yb
116
117
#endif // YB_TABLET_TABLET_TEST_UTIL_H