> On Aug. 1, 2017, 10:37 p.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?
> 
> Jan Schlicht wrote:
>     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.

I mean, `MockResourceProvider` should take `TestDriver` if you want to inject 
dependency for testing, instead of the reverse.


- Jie


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


On Aug. 7, 2017, 6:15 p.m., Jan Schlicht wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/61272/
> -----------------------------------------------------------
> 
> (Updated Aug. 7, 2017, 6:15 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/5/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jan Schlicht
> 
>

Reply via email to