> On June 1, 2015, 1:34 a.m., Adam B wrote: > > src/master/http.cpp, line 1038 > > <https://reviews.apache.org/r/34646/diff/3/?file=975522#file975522line1038> > > > > Could I ask you to write a quick unit test for this? > > haosdent huang wrote: > yes > > haosdent huang wrote: > @adam-mesos, I have a newbie problem. In the unit test, do I start a > multi-masters cluster to verify this? I search the exist unit tests, could > not find a exist snippet to start a multi-masters cluster. > > Adam B wrote: > Good question. Our unit test macros are not well documented, so I usually > find a couple of example tests to copy from. Check out > MasterAllocatorTest.FrameworkReregistersFirst and > MasterAllocatorTest.SlaveReregistersFirst, which actually do failover and > leader-election between two masters. > > https://github.com/apache/mesos/blob/0.22.1/src/tests/master_allocator_tests.cpp#L1295 > > haosdent huang wrote: > @adam-mesos Thank you very much! I miss them when I read the unit tests. > Let me try to add a unit test. > > haosdent huang wrote: > @adam-mesos In `MasterAllocatorTest.FrameworkReregistersFirst` and > `MasterAllocatorTest.SlaveReregistersFirst`, before them start the second > Master, it need call `this->ShutdownMasters();`. So there is only one master > when test. But this test case need two alive masters, I try to start two > masters, but it failed. So we have to change some thing make it possible to > start two alive masters in unit tests. > > Adam B wrote: > Okay. Sounds complicated. Just make sure you manually test. I'll drop > this issue. > > haosdent huang wrote: > @adam-mesos I try to find the reason why could not start two Master > instances in the test case serveral days ago. I think I am nearly to reach > the cause now. Let me reopen this issue and keep writing a test case for this. > > haosdent huang wrote: > @adam-mesos, sorry for not update this for a long time. Currently, in > [ProcessManager::spawn](https://github.com/apache/mesos/blob/0.22.1-rc6/3rdparty/libprocess/src/process.cpp#L2129-L2131), > we would check the process id exists or not. > ``` > if (processes.count(process->pid.id) > 0) { > return UPID(); > } else { > processes[process->pid.id] = process; > } > ``` > If it is exists, it would not spawn the processes. > For master, because we use a fixed pid.id. The above code pass "master" > as a fixed pid.id. So could not start two masters in our test cases now. > ``` > Master::Master( > Allocator* _allocator, > Registrar* _registrar, > Repairer* _repairer, > Files* _files, > MasterContender* _contender, > MasterDetector* _detector, > const Option<Authorizer*>& _authorizer, > const Option<shared_ptr<RateLimiter>>& _slaveRemovalLimiter, > const Flags& _flags) > : ProcessBase("master"), > ``` > But Slave use process::ID::generate() to generate id. The result of slave > id would be like this: slave(1), slave(2) and so on. > ``` > Slave::Slave(const slave::Flags& _flags, > MasterDetector* _detector, > Containerizer* _containerizer, > Files* _files, > GarbageCollector* _gc, > StatusUpdateManager* _statusUpdateManager, > ResourceEstimator* _resourceEstimator, > QoSController* _qosController) > : ProcessBase(process::ID::generate("slave")), > ``` > Let me change some code in tests/cluster.hpp and tests/clusters.cpp to > make start two masters possible.
This sounds like a non-trivial amount of effort. Let's not go too far down the rabbit-hole just for testing this patch. Since this is a broader testing requirement, could you create a separate JIRA for allowing tests to use two masters? - Adam ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/34646/#review85955 ----------------------------------------------------------- On June 1, 2015, 8:07 a.m., haosdent huang wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/34646/ > ----------------------------------------------------------- > > (Updated June 1, 2015, 8:07 a.m.) > > > Review request for mesos and Adam B. > > > Bugs: MESOS-1865 > https://issues.apache.org/jira/browse/MESOS-1865 > > > Repository: mesos > > > Description > ------- > > Return empty task list when current master is not a leader. > > > Diffs > ----- > > src/master/http.cpp 01dbdad9720a9cd30505683ae1117970cda918a0 > src/master/master.hpp c0cc2933a2cc094401f633df12356bda3d294564 > > Diff: https://reviews.apache.org/r/34646/diff/ > > > Testing > ------- > > make check > > when current master is not a leader, it would redirect to the leader master. > > ``` > $ curl -i http://master1:5050/master/tasks.json > HTTP/1.1 307 Temporary Redirect > Date: Mon, 01 Jun 2015 06:30:08 GMT > Location: http://master2:5050//master/tasks.json > Content-Length: 0 > ``` > > > Thanks, > > haosdent huang > >