<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Jun 18, 2018 at 1:37 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote:<br>
> On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer <<a href="mailto:nirsof@gmail.com" target="_blank">nirsof@gmail.com</a>> wrote:<br>
> > +    headers = {"Content-Type": "application/json",<br>
> > +               "Content-Length", str(len(buf))}<br>
<br>
There were a few Python syntax errors such as this one.  They<br>
can be found by running:<br>
<br>
  make -C v2v check TESTS=test-v2v-python-syntax.sh<br></blockquote><div><br></div><div>Cool. Why not include this in "make check"?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
However I have now fixed them.<br></blockquote><div><br></div><div>Thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> Do we have an easy way to test the plugin without running the entire<br>
> virt-v2v pipeline?<br>
<br>
Not really.  In fact we don't have any unit tests for -o rhv-upload<br>
functionality because there's no way to simulate the imageio server.<br></blockquote><div><br></div><div>Actually it is easy to use real imageio server for testing.</div><div><br></div><div>1. install ovirt-imageio-daemon</div><div>2. configure it for testing</div><div><br></div><div># /etc/ovirt-imageio-daemon/daemon.conf</div><div><div>[daemon]</div><div># directory with this structure</div><div>#     certs/</div><div>#         vdsmcert.pem</div><div>#     keys</div><div>#         vdsmkey.pem                                                                                                                                                                                 </div><div>pki_dir = test/pki</div><div>poll_interval = 0.1<br></div><div><br></div><div>[images]</div><div>port = 9876</div><div><br></div><div>[tickets]</div><div>socket = /tmp/ovirt-imageio-daemon.sock<br></div></div><div><br></div><div>3. Now you can run it</div><div><br></div><div>/usr/bin/ovirt-imageio-daemon</div><div><br></div><div>To upload, without real engine, you can install your own ticket like this:</div><div><br></div><div><div>1. Create a ticket json:</div><div><br></div><div>    $ cat ticket.json</div><div>    {</div><div>        "uuid": "test",</div><div>        "size": 1073741824,</div><div>        "url": "file:///var/tmp/sd-uukd/vol-uuid",</div><div>        "timeout": 3000,</div><div>        "ops": ["read", "write"]</div><div>    }</div><div><br></div><div>2. Install the ticket<br></div><div><br></div><div>    $ curl --unix-socket /tmp/vdsm/ovirt-imageio-daemon.sock \</div><div>          -X PUT \</div><div>          --upload-file ticket.json \</div><div>          <a href="http://localhost/tickets/test">http://localhost/tickets/test</a></div><div><br></div></div><div>3. Create the image:</div><div><br></div><div>file:</div><div>touch /var/tmp/sd-uuuid/vol-uuid</div><div><br></div><div>(note that the file system must support direct I/O)</div><div><br></div><div>block:</div><div>lvcreate -n vol-uuid -L 1g sd-uuid</div><div><br></div><div><br></div><div><div><div>At this point you can upload or download using this transfer_url:</div></div><div><a href="https://localhost:9876/images/test">https://localhost:9876/images/test</a></div></div><div><br></div><div><br></div><div>We can make it even easier by supporting command line options so </div><div>you don't need to change /etc/ovirt-imageio-daemon, or even install</div><div>the package. For example:</div><div><br></div><div>    git clone <a href="https://github.com/oVirt/ovirt-imageio.git">https://github.com/oVirt/ovirt-imageio.git</a></div><div>    src/ovirt-image/daemon/ovirt-imageio-daemon -f my-test.conf</div><div><br></div><div>Another option is to start the server from your tests like this. This</div><div>is how we run our tests.</div><div><br></div><div>from ovirt_imageio_daemon import server</div><div>from ovirt_imageio_daemon import config</div><div><br></div><div>config.daemon.pki_dir = test/pki</div><div>config.daemon.poll_interval = 0.1<br></div><div>config.images.port = 9876</div><div>config.tickets.socket = "/tmp/ovirt-imageio-daemon.sock"</div><div><br></div><div>server.start(config)<br></div><div><br></div><div># run your test here...</div><div><br></div><div>server.stop()<br></div><div><br></div><div>Note that we did not complete the port to python 3 yest, so upload tests</div><div>will work only with python 2.</div><div><br></div><div>The missing part is how to test without real engine. I think the best way would</div><div>be to monkeypatch the ovirtsdk module so it does not send any requests,</div><div>and instead return fake responses. This add risk of having incorrect mocked</div><div>response, or not detecting wrong calls, but will make testing very easy, which </div><div>make it easy for random contributors.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
However you can run virt-v2v locally against an oVirt instance without<br>
needing VMware.  The command is rather lengthy, but here it is:<br>
<br>
$ virt-builder fedora-27<br>
$ ./run virt-v2v -i disk /var/tmp/fedora-27.img \<br>
    -o rhv-upload \<br>
    -oc <a href="https://ovirt-engine.example.com/ovirt-engine/api" rel="noreferrer" target="_blank">https://ovirt-engine.example.com/ovirt-engine/api</a> \<br>
    -os ovirt-data \<br>
    -op /tmp/password \<br>
    -of raw \<br>
    -oo rhv-cafile=/tmp/ca.pem \<br>
    -oo rhv-direct<br>
<br>
/tmp/password should contain the oVirt admin password.<br>
/tmp/ca.pem should contain the oVirt CA cert.<br>
<br>
This will create a guest called ‘fedora-27’ which you'll need to<br>
delete (on oVirt) afterwards.  You can add ‘-on name’ to name it<br>
something else.<br></blockquote><div><br></div><div>Should we document this?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In any case I have fixed and verified this patch and will push it<br>
soon, thanks.<br>
<br>
Rich.<br>
<br>
-- <br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-builder quickly builds VMs from scratch<br>
<a href="http://libguestfs.org/virt-builder.1.html" rel="noreferrer" target="_blank">http://libguestfs.org/virt-builder.1.html</a><br>
</blockquote></div></div>