YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/yql/pgwrapper/create_initial_sys_catalog_snapshot.cc
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
// This program creates an "initial sys catalog snapshot" at a given directory that can later be
14
// used to bring up YSQL clusters without the time-consuming step of running initdb.
15
#include "yb/util/path_util.h"
16
#include "yb/util/status_log.h"
17
#include "yb/util/test_macros.h"
18
#include "yb/yql/pgwrapper/pg_wrapper_test_base.h"
19
20
DEFINE_string(initial_sys_catalog_snapshot_dest_path, "",
21
              "Destination path to write the initial sys catalog snapshot to");
22
23
namespace yb {
24
namespace pgwrapper {
25
26
class CreateInitialSysCatalogSnapshotTest : public PgWrapperTestBase {
27
 protected:
28
0
  void SetUp() override {
29
0
    PgWrapperTestBase::SetUp();
30
0
  }
31
32
0
  void UpdateMiniClusterOptions(ExternalMiniClusterOptions* options) override {
33
0
    if (FLAGS_initial_sys_catalog_snapshot_dest_path.empty()) {
34
      // Allow running this test without an argument.
35
0
      std::string test_tmpdir;
36
0
      CHECK_OK(Env::Default()->GetTestDirectory(&test_tmpdir));
37
0
      FLAGS_initial_sys_catalog_snapshot_dest_path = JoinPathSegments(
38
0
          test_tmpdir, "initial_sys_catalog_snapshot");
39
0
      LOG(INFO) << "Using a temporary directory! Sys catalog snapshot will not be saved.";
40
0
    }
41
0
    LOG(INFO) << "Creating initial system catalog snapshot at: "
42
0
              << FLAGS_initial_sys_catalog_snapshot_dest_path;
43
0
    options->extra_master_flags.emplace_back("--create_initial_sys_catalog_snapshot");
44
0
    options->extra_master_flags.emplace_back("--net_address_filter=ipv4_external,ipv4_all");
45
0
    options->extra_master_flags.emplace_back(
46
0
        "--initial_sys_catalog_snapshot_path=" + FLAGS_initial_sys_catalog_snapshot_dest_path);
47
0
    options->extra_master_flags.emplace_back("--master_auto_run_initdb");
48
0
  }
49
50
0
  int GetNumTabletServers() const override {
51
    // No tablet servers necessary to run initdb.
52
0
    return 0;
53
0
  }
54
};
55
56
TEST_F(CreateInitialSysCatalogSnapshotTest,
57
0
       YB_DISABLE_TEST_IN_TSAN(CreateInitialSysCatalogSnapshot)) {
58
  // All the work is done by the master on cluster startup.
59
0
}
60
61
}  // namespace pgwrapper
62
}  // namespace yb