> On May 7, 2016, 1:34 a.m., Jie Yu wrote:
> > src/tests/containerizer/cni_isolator_tests.cpp, line 42
> > <https://reviews.apache.org/r/46097/diff/6/?file=1374762#file1374762line42>
> >
> > Instead of using a script here, can we use code to get ip network and
> > name server information?
> >
> > You can take a look at `links()` and `IPNetwork::fromLinkDevice(..)` in
> > stout.
> >
> > I would suggest that we define a test fixture for the isolator tests
> > and get the ip network and nameserver address in the SetUp function. We can
> > also put the helpers to create plugin/config in the test fixture.
>
> Qian Zhang wrote:
> I see `link::eth0()` and `IPNetwork::fromLinkDevice(..)` can be used to
> get the IP of host public interface which is good, but how can we use code to
> get name server? It seems we do not have existing method to do so.
>
> What about I put creating plugin/config in `static void SetUpTestCase()`
> but still use script to get IP and name server?
I tried to use code to get IP and name servers rather than script, but I found
it will be hard to combine with C++ literal which may make the code hard to
read, like this:
```cpp
Result<net::IPNetwork> hostIPNetwork =
net::IPNetwork::fromLinkDevice(eth0.get(), AF_INET);
const string cniMockPlugin = R"~(
#!/bin/sh
echo "{"
echo " \"ip4\": {"
echo " \"ip\": \")~" + hostIPNetwork.get().address() + "/" +
hostIPNetwork.get().prefix() +
R"~(\""
echo " }"
echo "}"
)~";
```
Please note, I have not included name servers in the above code. There can be
multiple name servers, if we include them, it will make the above code more
complex, I think the current patch (do everything in a script) has better
readability. Or if we really want to do it in this way, can we just include the
first name server in the above code?
- Qian
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46097/#review132084
-----------------------------------------------------------
On May 6, 2016, 10:06 p.m., Qian Zhang wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46097/
> -----------------------------------------------------------
>
> (Updated May 6, 2016, 10:06 p.m.)
>
>
> Review request for mesos, Avinash sridharan and Jie Yu.
>
>
> Bugs: MESOS-5167
> https://issues.apache.org/jira/browse/MESOS-5167
>
>
> Repository: mesos
>
>
> Description
> -------
>
> Added the test "CniIsolatorTest.ROOT_LaunchCommandTask".
>
>
> Diffs
> -----
>
> src/Makefile.am 710e1644e2f0a8e9b87cc997b2211291f4e055fd
> src/tests/containerizer/cni_isolator_tests.cpp PRE-CREATION
>
> Diff: https://reviews.apache.org/r/46097/diff/
>
>
> Testing
> -------
>
> [ RUN ] CniIsolatorTest.ROOT_LaunchCommandTask
> + /home/stack/workspace/mesos/build/src/mesos-containerizer mount
> --help=false --operation=make-rslave --path=/
> + grep+ -E /tmp/CniIsolatorTest_ROOT_LaunchCommandTask_HRK4Dz/.+
> /proc/self/mountinfo
> + grepcut -v -d -f5
> d06b117d-518b-41e2-b8e0-62a12083773c
> + xargs --no-run-if-empty umount -l
> + mount -n --rbind
> /tmp/CniIsolatorTest_ROOT_LaunchCommandTask_HRK4Dz/provisioner/containers/d06b117d-518b-41e2-b8e0-62a12083773c/backends/copy/rootfses/7ea27011-cd3a-43b0-8301-b0b94d9f9b47
>
> /tmp/CniIsolatorTest_ROOT_LaunchCommandTask_HRK4Dz/slaves/18dea042-5bb5-4336-8bc8-358ed1fbf6dd-S0/frameworks/18dea042-5bb5-4336-8bc8-358ed1fbf6dd-0000/executors/60e6d35d-6d33-47ae-9c23-d2e5c913c892/runs/d06b117d-518b-41e2-b8e0-62a12083773c/.rootfs
> I0420 22:26:00.924844 9305 exec.cpp:150] Version: 0.29.0
> I0420 22:26:00.942319 9375 exec.cpp:225] Executor registered on agent
> 18dea042-5bb5-4336-8bc8-358ed1fbf6dd-S0
> Registered executor on mesos
> Starting task 60e6d35d-6d33-47ae-9c23-d2e5c913c892
> Forked command at 9382
> sh -c 'ls /'
> bin dev etc home lib linuxrc media mnt proc
> root run sbin sys tmp usr var
> Command exited with status 0 (pid: 9382)
> I0420 22:26:01.098331 9380 exec.cpp:399] Executor asked to shutdown
> [ OK ] CniIsolatorTest.ROOT_LaunchCommandTask (42603 ms)
>
>
> Thanks,
>
> Qian Zhang
>
>