Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated swagger spec for API 1.1.0 #175

Closed

Conversation

kacole2
Copy link

@kacole2 kacole2 commented Mar 8, 2016

the previous swagger spec was broken because of a basic code generation. this needs to be maintained more carefully and not reliant upon generated outputs. @akutz fixed this part: You must have a tag for a parameter of type . It was added wherever it was omitted, setting the schema to a variant type instead. It was omitted in a lot of requests as well as one response. Within the lookups, I (@kacole2) changed the lookup query reuirement from FALSE to TRUE. For some reason the code would fail to execute unless it was set to TRUE. There were some memory pointers happening and it will have to be looked at once again. To get a better idea of how this is all generated using go-swagger, checkout the gorackhd repo and follow the directions listed there. https://github.com/emccode/gorackhd

Signed-off-by: Kendrick Coleman kendrickcoleman@gmail.com

the previous swagger spec was broken because of a basic code generation. this needs to be maintained more carefully and not reliant upon generated outputs. @akutz fixed this part: You must have a  tag for a parameter of type . It was added wherever it was omitted, setting the schema to a variant type instead. It was omitted in a lot of requests as well as one response. Within the lookups, I (@kacole2) changed the lookup query reuirement from FALSE to TRUE. For some reason the code would fail to execute unless it was set to TRUE. There were some memory pointers happening and it will have to be looked at once again. To get a better idea of how this is all generated using go-swagger, checkout the gorackhd repo and follow the directions listed there. https://github.com/emccode/gorackhd

Signed-off-by: Kendrick Coleman <kendrickcoleman@gmail.com>
@JenkinsRHD
Copy link
Contributor

@RackHD/corecommitters please review.

@jlongever
Copy link
Contributor

ok to test

@@ -1432,7 +1437,7 @@ paths:
- name: q
in: query
description: query object to pass through to waterline.
required: false
required: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benbp can you take a quick look at the code and verify? The relevant line is https://github.com/RackHD/on-http/blob/master/lib/api/1.1/northbound/lookups.js#L31, so the main branch of this definitely wants to see a q there, but I think the intent was that waterline.lookups.findByTerm(null) would return all values. If that's correct (and works) then q isn't required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i originally tried to make this work with Q set to FALSE but just couldn't. as soon as i switched it to TRUE, then all of sudden the queries would work. Let me try testing again by throwing in nil. https://github.com/emccode/docker-machine-rackhd/blob/master/rackhd.go#L155

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just tested this and here are the results.

When lookups q query is set to TRUE:

  1. Pass in q as a string (Node, IP, Mac) and the returned result is the expected array
  2. Pass in nil, then and error comes back with cannot use nil as type string in field value
  3. Pass in "" (completely blank), the returned result is everything in an array as expected

When lookups q query is set to FALSE:

  1. Pass in q as a string (Node, IP, Mac) and the returned result is the error: cannot use "56dde3441722c192796e3a38" (type string) as type *string in field value
  2. Pass in nil, the returned result is everything in an array as expected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on-http 1.1 API implementation doesn't use swagger in any capacity. The source of that validation error message is not RackHD.

When the python library is updated to use this change (occurs post commit), this should break our functional tests here: https://github.com/RackHD/RackHD/blob/master/test/tests/api/v1_1/lookups_tests.py#L51.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zyoung51 comment ^^ still holds true when required is set to true. The python functional tests run tests without the 'q' parameter, both library and functional tests will need to be updated if we force 'q' parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlongever The tests and library are correct now. We shouldn't be setting the required flag for an optional parameter even if it's not actually enforced by the API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, we're using swagger-codegen and haven't had issues with the optional 'q' parameter.

@heckj
Copy link
Member

heckj commented Mar 8, 2016

Not sure about the required q part - but the rest looks great! 👍 with other validation on the q required thing in GET /lookups

@JenkinsRHD
Copy link
Contributor

*** BUILD #578 ***

@brianparry
Copy link
Contributor

test this please

@kacole2
Copy link
Author

kacole2 commented Mar 15, 2016

@brianparry i have my manual testing notes in the thread. unless that wasn't directed at me.

@zyoung51
Copy link
Contributor

@kacole2 Brian's message is a trigger phrase for Jenkins and is only meant for that system.

@heckj
Copy link
Member

heckj commented Mar 15, 2016

@kacole2 that's the phrase that commiters can invoke to have jenkins do a test build/run against the code - not meant for you specifically

@kacole2
Copy link
Author

kacole2 commented Mar 15, 2016

@zyoung51 @heckj sorry. didn't know what wizardry you all had here!

@JenkinsRHD
Copy link
Contributor

*** BUILD #626 ***
Test Name: Http.Api.Pollers "before each" hook: reset test DB for "should create an SNMP poller with POST /pollers"
Error Details: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
Stack Trace: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

@brianparry
Copy link
Contributor

Sorry for the confusion @kacole2. That comment was for Jenkins not you :)

@jlongever
Copy link
Contributor

Jenkins, test this please

@heckj
Copy link
Member

heckj commented Apr 13, 2016

Mr Jenkins bot, test this please

@heckj
Copy link
Member

heckj commented Apr 13, 2016

@RackHD/corecommitters looks like earlier testing hung or something, trying to retrigger

@jlongever
Copy link
Contributor

bah, seen this with other checks. The status gets stuck on running. I've had to close/reopen the PR before to "dislodge" it.

@heckj
Copy link
Member

heckj commented Apr 13, 2016

will do that, thanks

@heckj heckj closed this Apr 13, 2016
@heckj heckj reopened this Apr 13, 2016
@JenkinsRHD
Copy link
Contributor

*** BUILD #883 ***
Test Name: test_node_workflows_post
Error Details: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Length': '128', 'X-Powered-By': 'Express', 'Connection': 'keep-alive', 'ETag': 'W/"80-7OjUGBy4o6RiaRnKGDICnw"', 'Date': 'Wed, 13 Apr 2016 18:15:01 GMT', 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json; charset=utf-8'})
HTTP response body: {"message":"BadRequestError: required option user for task Task.Obm.Ipmi.CreateSettings in graph Graph.Obm.Ipmi.CreateSettings"}

-------------------- >> begin captured logging << --------------------
tests.api.v2_0.workflows_tests: INFO: starting amqp listener for node 570e8b67d01211d20774bf7e
amqp: DEBUG: Start from server, version: 0.9, properties: {u'information': u'Licensed under the MPL.  See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2013 GoPivotal, Inc.', u'capabilities': {u'exchange_exchange_bindings': True, u'connection.blocked': True, u'authentication_failure_close': True, u'basic.nack': True, u'consumer_priorities': True, u'consumer_cancel_notify': True, u'publisher_confirms': True}, u'platform': u'Erlang/OTP', u'version': u'3.2.4'}, mechanisms: [u'AMQPLAIN', u'PLAIN'], locales: [u'en_US']
amqp: DEBUG: Open OK!
--------------------- >> end captured logging << ---------------------
Stack Trace:   File "/usr/lib/python2.7/unittest/case.py", line 331, in run
    testMethod()
  File "/usr/lib/python2.7/unittest/case.py", line 1043, in runTest
    self._testFunc()
  File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func
    compatability.capture_type_error(s_func)
  File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error
    func()
  File "/tmp/.venv/local/lib/python2.7/site-packages/proboscis/case.py", line 350, in func
    func(test_case.state.get_state())
  File "/home/jenkins/workspace/on-http/RackHD/test/tests/api/v2_0/workflows_tests.py", line 189, in test_node_workflows_post
    Api().nodes_post_workflow_by_id(id, name='Graph.noop-example', body={})
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/apis/api_api.py", line 2594, in nodes_post_workflow_by_id
    callback=params.get('callback'))
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/api_client.py", line 322, in call_api
    response_type, auth_settings, callback)
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/api_client.py", line 149, in __call_api
    post_params=post_params, body=body)
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/api_client.py", line 358, in request
    body=body)
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/rest.py", line 208, in POST
    body=body)
  File "/tmp/.venv/local/lib/python2.7/site-packages/on_http_api2_0/rest.py", line 177, in request
    raise ApiException(http_resp=r)
'(400)\nReason: Bad Request\nHTTP response headers: HTTPHeaderDict({\'Content-Length\': \'128\', \'X-Powered-By\': \'Express\', \'Connection\': \'keep-alive\', \'ETag\': \'W/"80-7OjUGBy4o6RiaRnKGDICnw"\', \'Date\': \'Wed, 13 Apr 2016 18:15:01 GMT\', \'Access-Control-Allow-Origin\': \'*\', \'Content-Type\': \'application/json; charset=utf-8\'})\nHTTP response body: {"message":"BadRequestError: required option user for task Task.Obm.Ipmi.CreateSettings in graph Graph.Obm.Ipmi.CreateSettings"}\n\n-------------------- >> begin captured logging << --------------------\ntests.api.v2_0.workflows_tests: INFO: starting amqp listener for node 570e8b67d01211d20774bf7e\namqp: DEBUG: Start from server, version: 0.9, properties: {u\'information\': u\'Licensed under the MPL.  See http://www.rabbitmq.com/\', u\'product\': u\'RabbitMQ\', u\'copyright\': u\'Copyright (C) 2007-2013 GoPivotal, Inc.\', u\'capabilities\': {u\'exchange_exchange_bindings\': True, u\'connection.blocked\': True, u\'authentication_failure_close\': True, u\'basic.nack\': True, u\'consumer_priorities\': True, u\'consumer_cancel_notify\': True, u\'publisher_confirms\': True}, u\'platform\': u\'Erlang/OTP\', u\'version\': u\'3.2.4\'}, mechanisms: [u\'AMQPLAIN\', u\'PLAIN\'], locales: [u\'en_US\']\namqp: DEBUG: Open OK!\n--------------------- >> end captured logging << ---------------------'

@benbp
Copy link
Contributor

benbp commented Apr 18, 2016

test this please

@JenkinsRHD
Copy link
Contributor

*** BUILD #944 ***

@anhou
Copy link
Member

anhou commented Apr 19, 2016

test this please

1 similar comment
@benbp
Copy link
Contributor

benbp commented Apr 22, 2016

test this please

@anhou
Copy link
Member

anhou commented Jun 15, 2016

@kacole2 @brianparry @jlongever is this PR still valid? it's pending for a long time. not sure if it's valid after two months' many codes update, and conflicts need to be resolved.

@kacole2
Copy link
Author

kacole2 commented Jun 15, 2016

@anhou close it. will re-open if this isn't fixed in v2.0 API. The gorackhd library is going to keep a manual swagger-spec with this changed to keep it stable and working as expected

@kacole2 kacole2 closed this Jun 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants