mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Schlicht <...@mesosphere.io>
Subject Re: Review Request 61272: Added a MockResourceProvider.
Date Thu, 03 Aug 2017 09:35:48 GMT


> On Aug. 2, 2017, 12:37 a.m., Jie Yu wrote:
> > src/tests/mesos.hpp
> > Lines 2287-2291 (patched)
> > <https://reviews.apache.org/r/61272/diff/2/?file=1786382#file1786382line2287>
> >
> >     This is a bit counter intuitive. I was expecting that MockResourceProvider will
take a real Driver:
> >     ```
> >     class MockResourceProvider
> >     {
> >     public:
> >       MockResourceProvider(
> >           const URL& endpoint,
> >           ContentType contentType)
> >         : driver(
> >               Owned<EndpointDetector>(new ConstantEndpointDetector(endpoint)),
> >               contentType,
> >               [this]() { connected(); },
> >               [this]() { disconnected(); },
> >               [this](std::queue<Event> events) {
> >                 while (!events.empty()) {
> >                   Event event = std::move(events.front());
> >                   events.pop();
> >                   received(event);
> >                 }
> >               }) {}
> >               
> >       MOCK_METHOD0_T(connected, void());
> >       MOCK_METHOD0_T(disconnected, void());
> >       ...
> >     
> >     private:
> >       Driver driver;
> >     };
> >     ```
> 
> Jan Schlicht wrote:
>     The driver needs to be accessible in the test case to allow things like
>     ```
>       v1::MockResourceProvider resourceProvider;
>       v1::resource_provider::TestDriver driver;
>       ...
>     
>       Future<Event::Subscribed> subscribed;
>       EXPECT_CALL(*resourceProvider, subscribed(_))
>         .WillOnce(FutureArg<0>(&subscribed));
>     
>       mesos::v1::ResourceProviderInfo resourceProviderInfo;
>       resourceProviderInfo.set_type("org.apache.mesos.rp.test");
>       resourceProviderInfo.set_name("test");
>     
>       // Creates a 'SUBSCRIBE' message and sends it using the driver.
>       subscribe(&driver, resourceProviderInfo);
>     
>       AWAIT_READY(subscribed);
>     ```
> 
> Jie Yu wrote:
>     hum, why can't we use a real RP manager to send the message?

Sorry, I don't understand. The driver sends `Call`s to the RP manager and receives `Event`s
that it relays to `MockResourceProvider`. We need to separate driver and `MockResourceProvider`
to be able to set expectations on our mock, before the driver starts. E.g. we'd expect `MockResourceProvider::connected`
to be called when a connection to the RP manager has been established. We need to set this
expectation (by creating a `Future` and `EXPECT_CALL` on the `MockResourceProvider` instance)
before a driver instanciated, hence have to keep them separated.


- Jan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/61272/#review181922
-----------------------------------------------------------


On Aug. 2, 2017, 1:38 p.m., Jan Schlicht wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/61272/
> -----------------------------------------------------------
> 
> (Updated Aug. 2, 2017, 1:38 p.m.)
> 
> 
> Review request for mesos, Benjamin Bannier and Jie Yu.
> 
> 
> Bugs: MESOS-7469
>     https://issues.apache.org/jira/browse/MESOS-7469
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added a MockResourceProvider.
> 
> 
> Diffs
> -----
> 
>   src/tests/mesos.hpp 6f06261d81870b923b7053daf8205327c4ac6a45 
> 
> 
> Diff: https://reviews.apache.org/r/61272/diff/3/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jan Schlicht
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message