MCPcopy Create free account
hub / github.com/apache/impala / TEST_F

Function TEST_F

be/src/runtime/coordinator-backend-state-test.cc:71–104  ·  view source on GitHub ↗

Validate the state machine of BackendResourceState by testing that the following conditions hold: All BackendStates are initially marked as IN_USE. Releasing all Backends transitions all Backends to the RELEASED state.

Source from the content-addressed store, hash-verified

69/// * All BackendStates are initially marked as IN_USE.
70/// * Releasing all Backends transitions all Backends to the RELEASED state.
71TEST_F(CoordinatorBackendStateTest, StateMachine) {
72 // Initialize a BackendResourceState with three BackendStates.
73 int num_backends = 3;
74 std::vector<Coordinator::BackendState*> backend_states;
75 Coordinator::BackendState* coordinator_backend = nullptr;
76 MakeBackendStates(num_backends, &coordinator_backend, &backend_states);
77 Coordinator::BackendResourceState* backend_resource_state =
78 pool_.Add(new Coordinator::BackendResourceState(backend_states));
79
80 // Assert that all BackendStates are initially in the IN_USE state.
81 ASSERT_EQ(backend_resource_state->backend_resource_states_.size(), num_backends);
82 for (auto backend_state : backend_resource_state->backend_resource_states_) {
83 ASSERT_EQ(
84 backend_state.second, Coordinator::BackendResourceState::ResourceState::IN_USE);
85 }
86
87 // Assert that releasing an empty vector of BackendStates does not transition any
88 // BackendState to the RELEASED state.
89 std::vector<Coordinator::BackendState*> empty_backend_states;
90 backend_resource_state->BackendsReleased(empty_backend_states);
91 ASSERT_TRUE(empty_backend_states.empty());
92 ASSERT_EQ(backend_resource_state->backend_resource_states_.size(), num_backends);
93 for (auto backend_state : backend_resource_state->backend_resource_states_) {
94 ASSERT_EQ(
95 backend_state.second, Coordinator::BackendResourceState::ResourceState::IN_USE);
96 }
97
98 // Assert that releasing all BackendStates transitions all BackendStates from
99 // IN_USE to RELEASED.
100 backend_resource_state->BackendsReleased(backend_states);
101 std::vector<Coordinator::BackendState*> unreleased_backend_states =
102 backend_resource_state->CloseAndGetUnreleasedBackends();
103 ASSERT_EQ(unreleased_backend_states.size(), 0);
104}
105
106/// Validate the 'Coordinator Only' heuristic.
107TEST_F(CoordinatorBackendStateTest, CoordinatorOnly) {

Callers

nothing calls this directly

Calls 8

BackendsReleasedMethod · 0.80
push_backMethod · 0.80
MarkBackendFinishedMethod · 0.80
clearMethod · 0.65
AddMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected