YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/yql/pgwrapper/pg_mini_test_base.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_YQL_PGWRAPPER_PG_MINI_TEST_BASE_H
15
#define YB_YQL_PGWRAPPER_PG_MINI_TEST_BASE_H
16
17
#include "yb/integration-tests/mini_cluster.h"
18
#include "yb/integration-tests/yb_mini_cluster_test_base.h"
19
20
#include "yb/yql/pgwrapper/libpq_utils.h"
21
#include "yb/yql/pgwrapper/pg_wrapper.h"
22
23
namespace yb {
24
namespace pgwrapper {
25
26
class PgMiniTestBase : public YBMiniClusterTestBase<MiniCluster> {
27
 protected:
28
  // This allows modifying flags before we start the postgres process in SetUp.
29
0
  virtual void BeforePgProcessStart() {
30
0
  }
31
32
  void DoTearDown() override;
33
34
  void SetUp() override;
35
36
0
  virtual size_t NumMasters() {
37
0
    return 1;
38
0
  }
39
40
0
  virtual size_t NumTabletServers() {
41
0
    return 3;
42
0
  }
43
44
  // This allows modifying the logic to decide which tablet server to run postgres on -
45
  // by default, randomly picked out of all the tablet servers.
46
  virtual const std::shared_ptr<tserver::MiniTabletServer> PickPgTabletServer(
47
     const MiniCluster::MiniTabletServers& servers);
48
49
0
  Result<PGConn> Connect() {
50
0
    return PGConn::Connect(pg_host_port_);
51
0
  }
52
53
0
  Result<PGConn> ConnectToDB(const std::string& dbname) {
54
0
    return PGConn::Connect(pg_host_port_, dbname);
55
0
  }
56
57
  CHECKED_STATUS RestartCluster();
58
59
0
  const HostPort& pg_host_port() const {
60
0
    return pg_host_port_;
61
0
  }
62
63
 private:
64
  Result<PgProcessConf> CreatePgProcessConf(uint16_t port);
65
66
  std::unique_ptr<PgSupervisor> pg_supervisor_;
67
  HostPort pg_host_port_;
68
};
69
70
} // namespace pgwrapper
71
} // namespace yb
72
73
#endif // YB_YQL_PGWRAPPER_PG_MINI_TEST_BASE_H