<div dir="ltr">Hi Ruben,<div><br></div><div>Did a little debugging for you...</div><div><br></div><div>1) Run your unit tests</div><div>$ tox -epy34 congress.tests.datasources.test_magnum<br></div><div>...</div><div>  File "/Users/tim/opencode/congress/congress/tests/datasources/test_magnum_driver.py", line 3, in <module></div><div>    from congress.datasources import magnum_driver</div><div>  File "/Users/tim/opencode/congress/congress/datasources/magnum_driver.py", line 51</div><div>    self.magnum = magnum_client.Client(session=session)</div><div>    ^</div><div>IndentationError: unexpected indent</div><div><br></div><div>The IndenetationError says you haven't lined up the code correctly.  Python is sensitive to whitespace.  I fixed this.  </div><div><br></div><div>2) Run unit tests again.</div><div><div>$ tox -epy34 congress.tests.datasources.test_magnum</div><div>..</div><div>  File "/Users/tim/opencode/congress/congress/datasources/magnum_driver.py", line 1, in <module></div><div>    from magnumclient import client as magnum_client</div></div><div><br></div><div>Here the problem is that the package magnumclient doesn't exist.  You need to add the python-magnumclient to the file requirements.txt.</div><div>I fixed this for you as well.</div><div><br></div><div>3) Run unit tests again</div><div><div>$ tox -epy34 congress.tests.datasources.test_magnum</div><br class="inbox-inbox-Apple-interchange-newline"></div><div>Forgot to capture the output this time, but there was a test failure.  I went ahead and uncommented the two translators that you wrote </div><div>because they seemed to be doing the right thing; that required combining your two unit tests into 1.  </div><div><br></div><div>4) Run unit tests again</div><div>$ tox -epy34 congress.tests.datasources.test_magnum<br class="inbox-inbox-Apple-interchange-newline"></div><div><br></div><div><div>Traceback (most recent call last):</div><div>  File "/Users/tim/opencode/congress/congress/tests/datasources/test_magnum_driver.py", line 97, in test_cluster_template_update_from_datasource</div><div>    self.assertEqual(self.driver.state, expected)</div><div>  File "/Users/tim/opencode/congress/.tox/py34/lib/python3.4/site-packages/testtools/testcase.py", line 411, in assertEqual</div><div>    self.assertThat(observed, matcher, message)</div><div>  File "/Users/tim/opencode/congress/.tox/py34/lib/python3.4/site-packages/testtools/testcase.py", line 498, in assertThat</div><div>    raise mismatch_error</div>





<div>testtools.matchers._impl.MismatchError: !=:</div><div>reference = {'cluster': {('None', 'k8s-cluster', 'None', 1, 1, 'CREATE_FAILED')},<br></div><div> 'cluster_template': {('None', 'k8s-cluster-template', 'None', 'None')}}</div><div>reference = {'cluster': {('f88cb9c7-1e5d-42cb-b0dc-d9c3d0872ddf',</div><div>              'k8s-cluster',</div><div>              'testkey',</div><div>              1,</div><div>              1,</div><div>              'CREATE_FAILED')},</div><div> 'cluster_template': {('3ddeaf4f-af3d-4534-9558-59bf28b1578b',</div><div>                       'k8s-cluster-template',</div><div>                       'kubernetes',</div><div>                       'flannel')}}</div><div>actual    = {'cluster': {('None', 'k8s-cluster', 'None', 1, 1, 'CREATE_FAILED')},</div><div> 'cluster_template': {('None', 'k8s-cluster-template', 'None', 'None')}}</div><div><br></div><div>What's happening here is that the output of the translator does not match what the test says the output should be.  The problem is that there's a mismatch between the keys in the data that you've mocked out (e.g. mock_cluster_template) and the fieldnames in the translator (e.g. cluster_template_translator).<br></div></div><div><br></div><div>In the translator below you say the field names are 'id', 'name', 'COE', and 'Network_driver'.  In the data you mocked out, the closest field names I can see are 'uuid', 'name', 'coe', and 'network_driver'.  So fieldname 'name' matches the mocked out data, but the other field names do not.  (Field names are case sensitive.)  So if you change it so the fieldnames and the mock-data match, your unit test should pass. </div><div><br></div><div><div>    cluster_template_translator = {</div><div>        'translation-type': 'HDICT',</div><div>        'table-name': CLUSTER_TEMPLATE,</div><div>        'selector-type': 'DICT_SELECTOR',</div><div>        'field-translators':</div><div>          ({'fieldname': 'id', 'translator': value_trans},</div><div>           {'fieldname': 'name', 'translator': value_trans},</div><div>           {'fieldname': 'COE', 'translator': value_trans},</div><div>           {'fieldname': 'Network_driver', 'translator': value_trans})}</div></div><div><br></div><div>5) Of course, just because the unit tests pass doesn't mean the driver is correct.  The translator fieldnames need to match the actual data that magnum returns when you ask for the clusters and cluster_templates.  One option is to read through the python-magnumclient code to see what fields it returns; the other is to run the commands yourself from the commandline to see what they return; another is to look at the Congress logs when the magnum driver is running (with debug=True in /etc/congress/congress.conf).</div><div><br></div><div>6) I pushed all my changes as a revision on top of one of your commits.  We always include the code and the unit tests as one commit.  So now there's 1 commit that you can download to your local machine and continue editing.  Or you can just look at the code in gerrit and make changes to your code manually.</div><div><br></div><div><a href="https://review.openstack.org/#/c/397150/">https://review.openstack.org/#/c/397150/</a><br></div><div><br></div><div>To download, the safest thing is to create a new branch and apply the changes on top of that branch.    You can also skip the 'git checkout' step if you want to apply the changes on top of the ones you already have, resolve conflicts, and then squash all the commits together.</div><div>$ cd /path/to/congress</div><div>$ git checkout origin/master -b <pick-a-new-name></div><div>$ git fetch <a href="https://git.openstack.org/openstack/congress">https://git.openstack.org/openstack/congress</a> refs/changes/50/397150/4 && git cherry-pick FETCH_HEAD</div><div><br></div><div>Hope that helps,</div><div>Tim</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 14, 2016 at 10:02 AM Adrian Otto <<a href="mailto:adrian.otto@rackspace.com">adrian.otto@rackspace.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ruben,<br class="gmail_msg">
<br class="gmail_msg">
I found the following two reviews:<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://review.openstack.org/397150" rel="noreferrer" class="gmail_msg" target="_blank">https://review.openstack.org/397150</a> Magnum_driver for congress<br class="gmail_msg">
<a href="https://review.openstack.org/397151" rel="noreferrer" class="gmail_msg" target="_blank">https://review.openstack.org/397151</a> Test for magnum_driver<br class="gmail_msg">
<br class="gmail_msg">
Are these what you are referring to, or is it something else?<br class="gmail_msg">
<br class="gmail_msg">
Thanks,<br class="gmail_msg">
<br class="gmail_msg">
Adrian<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
> On Nov 14, 2016, at 4:13 AM, Ruben <<a href="mailto:r.manganiello1@studenti.unisa.it" class="gmail_msg" target="_blank">r.manganiello1@studenti.unisa.it</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> Hi everybody,<br class="gmail_msg">
> I've added the magnum_driver code, that I'm trying to write for congress, to review.<br class="gmail_msg">
> I think that I've made some errors.<br class="gmail_msg">
><br class="gmail_msg">
> I hope in your help.<br class="gmail_msg">
> Ruben<br class="gmail_msg">
><br class="gmail_msg">
> __________________________________________________________________________<br class="gmail_msg">
> OpenStack Development Mailing List (not for usage questions)<br class="gmail_msg">
> Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" class="gmail_msg" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br class="gmail_msg">
> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
__________________________________________________________________________<br class="gmail_msg">
OpenStack Development Mailing List (not for usage questions)<br class="gmail_msg">
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" class="gmail_msg" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br class="gmail_msg">
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br class="gmail_msg">
</blockquote></div>