YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/integration-tests/cluster_trace-test.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
14
#include "yb/integration-tests/external_mini_cluster-itest-base.h"
15
#include "yb/integration-tests/test_workload.h"
16
17
namespace yb {
18
19
class TraceClusterTest : public ExternalMiniClusterITestBase {
20
 public:
21
0
  void SetTracingFlag(bool enabled) {
22
0
    for (int i = 0; i < 3; ++i) {
23
0
      ASSERT_OK(cluster_->SetFlag(
24
0
          cluster_->tablet_server(i), "enable_tracing", enabled ? "1" : "0"));
25
0
    }
26
0
    WaitForInserts(workload_->rows_inserted() + 1000);
27
0
  }
28
29
1
  void PrepareCluster() {
30
1
    ASSERT_NO_FATALS(StartCluster());
31
1
    workload_.reset(new TestWorkload(cluster_.get()));
32
1
    workload_->Setup();
33
1
    workload_->Start();
34
    // Wait for some data to come in.
35
1
    WaitForInserts(100);
36
1
  }
37
38
0
  void WaitForInserts(int64_t num_rows) {
39
0
    while (workload_->rows_inserted() < num_rows) {
40
0
      SleepFor(MonoDelta::FromMilliseconds(10));
41
0
    }
42
0
  }
43
44
  std::unique_ptr<TestWorkload> workload_;
45
};
46
47
1
TEST_F(TraceClusterTest, TestTracingUnderLoad) {
48
  // Start the cluster and then the workload.
49
1
  PrepareCluster();
50
51
  // Cycle through enable/disable a bunch of times.
52
1
  for (int i = 0; i < 10; ++i) {
53
0
    SetTracingFlag(static_cast<bool>(i % 2));
54
0
  }
55
56
  // Stop the workload.
57
1
  workload_->StopAndJoin();
58
1
  cluster_->AssertNoCrashes();
59
1
}
60
61
}  // namespace yb