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

Function TEST_F

src/tests/http_fault_tolerance_tests.cpp:86–171  ·  view source on GitHub ↗

This test verifies that a framework attempting to resubscribe with a different principal during its failover timeout gets an error.

Source from the content-addressed store, hash-verified

84// with a different principal during its failover timeout
85// gets an error.
86TEST_F(HttpFaultToleranceTest, FrameworkPrincipalChangeFails)
87{
88 master::Flags flags = CreateMasterFlags();
89 Try<Owned<cluster::Master>> master = StartMaster(flags);
90 ASSERT_SOME(master);
91
92 v1::FrameworkID frameworkId;
93
94 // Launch the first (i.e., failing) scheduler and wait until it receives
95 // a `SUBSCRIBED` event to launch the second (i.e., failover) scheduler.
96 {
97 v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
98 frameworkInfo.set_failover_timeout(Weeks(2).secs());
99
100 auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
101
102 Future<Nothing> connected;
103 EXPECT_CALL(*scheduler, connected(_))
104 .WillOnce(v1::scheduler::SendSubscribe(frameworkInfo));
105
106 EXPECT_CALL(*scheduler, heartbeat(_))
107 .WillRepeatedly(Return()); // Ignore heartbeats.
108
109 Future<Event::Subscribed> subscribed;
110 EXPECT_CALL(*scheduler, subscribed(_, _))
111 .WillOnce(FutureArg<1>(&subscribed));
112
113 v1::scheduler::TestMesos mesos(
114 master.get()->pid,
115 ContentType::JSON,
116 scheduler);
117
118 AWAIT_READY(subscribed);
119
120 frameworkId = subscribed->framework_id();
121 }
122
123
124 // Now launch the second (i.e., failover) scheduler using the framework id
125 // recorded from the first scheduler but another set of valid credentials.
126 // The scheduler should get an error instead of "Subscribed" message.
127 // The master should disconnect the scheduler after sending an error.
128 {
129 v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
130
131 frameworkInfo.mutable_id()->CopyFrom(frameworkId);
132 frameworkInfo.set_principal(v1::DEFAULT_CREDENTIAL_2.principal());
133
134 auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
135
136 // We do not resubscribe after the master disconnects us.
137 Future<Nothing> connected;
138 EXPECT_CALL(*scheduler, connected(_))
139 .WillOnce(v1::scheduler::SendSubscribe(frameworkInfo, frameworkId))
140 .WillRepeatedly(Return());
141
142 EXPECT_CALL(*scheduler, heartbeat(_))
143 .WillRepeatedly(Return()); // Ignore heartbeats.

Callers

nothing calls this directly

Calls 15

WeeksClass · 0.85
FutureSatisfyFunction · 0.85
errorFunction · 0.85
NoneClass · 0.85
shutdownFunction · 0.85
CopyFromMethod · 0.80
principalMethod · 0.80
createDetectorMethod · 0.80
dataMethod · 0.80
createTaskFunction · 0.70
sendMethod · 0.65
createFunction · 0.50

Tested by

no test coverage detected