/proc/self/cwd/test/mocks/upstream/host_set.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/upstream/upstream.h" |
4 | | |
5 | | #include "source/common/common/callback_impl.h" |
6 | | #include "source/common/upstream/upstream_impl.h" |
7 | | |
8 | | #include "gmock/gmock.h" |
9 | | #include "gtest/gtest.h" |
10 | | |
11 | | namespace Envoy { |
12 | | namespace Upstream { |
13 | | class MockHostSet : public HostSet { |
14 | | public: |
15 | | MockHostSet(uint32_t priority = 0, |
16 | | uint32_t overprovisioning_factor = kDefaultOverProvisioningFactor); |
17 | | ~MockHostSet() override; |
18 | | |
19 | 9.83k | void runCallbacks(const HostVector added, const HostVector removed) { |
20 | 9.83k | THROW_IF_NOT_OK(member_update_cb_helper_.runCallbacks(priority(), added, removed)); |
21 | 9.83k | } |
22 | | |
23 | | ABSL_MUST_USE_RESULT Common::CallbackHandlePtr |
24 | 52.6k | addMemberUpdateCb(PrioritySet::PriorityUpdateCb callback) { |
25 | 52.6k | return member_update_cb_helper_.add(callback); |
26 | 52.6k | } |
27 | | |
28 | | // Upstream::HostSet |
29 | | MOCK_METHOD(const HostVector&, hosts, (), (const)); |
30 | | MOCK_METHOD(HostVectorConstSharedPtr, hostsPtr, (), (const)); |
31 | | MOCK_METHOD(const HostVector&, healthyHosts, (), (const)); |
32 | | MOCK_METHOD(HealthyHostVectorConstSharedPtr, healthyHostsPtr, (), (const)); |
33 | | MOCK_METHOD(const HostVector&, degradedHosts, (), (const)); |
34 | | MOCK_METHOD(DegradedHostVectorConstSharedPtr, degradedHostsPtr, (), (const)); |
35 | | MOCK_METHOD(const HostVector&, excludedHosts, (), (const)); |
36 | | MOCK_METHOD(ExcludedHostVectorConstSharedPtr, excludedHostsPtr, (), (const)); |
37 | | MOCK_METHOD(const HostsPerLocality&, hostsPerLocality, (), (const)); |
38 | | MOCK_METHOD(HostsPerLocalityConstSharedPtr, hostsPerLocalityPtr, (), (const)); |
39 | | MOCK_METHOD(const HostsPerLocality&, healthyHostsPerLocality, (), (const)); |
40 | | MOCK_METHOD(HostsPerLocalityConstSharedPtr, healthyHostsPerLocalityPtr, (), (const)); |
41 | | MOCK_METHOD(const HostsPerLocality&, degradedHostsPerLocality, (), (const)); |
42 | | MOCK_METHOD(HostsPerLocalityConstSharedPtr, degradedHostsPerLocalityPtr, (), (const)); |
43 | | MOCK_METHOD(const HostsPerLocality&, excludedHostsPerLocality, (), (const)); |
44 | | MOCK_METHOD(HostsPerLocalityConstSharedPtr, excludedHostsPerLocalityPtr, (), (const)); |
45 | | MOCK_METHOD(LocalityWeightsConstSharedPtr, localityWeights, (), (const)); |
46 | | MOCK_METHOD(absl::optional<uint32_t>, chooseHealthyLocality, ()); |
47 | | MOCK_METHOD(absl::optional<uint32_t>, chooseDegradedLocality, ()); |
48 | | MOCK_METHOD(uint32_t, priority, (), (const)); |
49 | 12.4k | uint32_t overprovisioningFactor() const override { return overprovisioning_factor_; } |
50 | 0 | void setOverprovisioningFactor(const uint32_t overprovisioning_factor) { |
51 | 0 | overprovisioning_factor_ = overprovisioning_factor; |
52 | 0 | } |
53 | 6.24k | bool weightedPriorityHealth() const override { return weighted_priority_health_; } |
54 | | |
55 | | HostVector hosts_; |
56 | | HostVector healthy_hosts_; |
57 | | HostVector degraded_hosts_; |
58 | | HostVector excluded_hosts_; |
59 | | HostsPerLocalitySharedPtr hosts_per_locality_{new HostsPerLocalityImpl()}; |
60 | | HostsPerLocalitySharedPtr healthy_hosts_per_locality_{new HostsPerLocalityImpl()}; |
61 | | HostsPerLocalitySharedPtr degraded_hosts_per_locality_{new HostsPerLocalityImpl()}; |
62 | | HostsPerLocalitySharedPtr excluded_hosts_per_locality_{new HostsPerLocalityImpl()}; |
63 | | LocalityWeightsConstSharedPtr locality_weights_{{}}; |
64 | | Common::CallbackManager<uint32_t, const HostVector&, const HostVector&> member_update_cb_helper_; |
65 | | uint32_t priority_{}; |
66 | | uint32_t overprovisioning_factor_{}; |
67 | | bool weighted_priority_health_{false}; |
68 | | bool run_in_panic_mode_ = false; |
69 | | }; |
70 | | } // namespace Upstream |
71 | | |
72 | | } // namespace Envoy |