Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Client Library HIL | query calls #617

Merged
merged 84 commits into from
Apr 24, 2017
Merged
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
e75786c
client library support for HIL query calls.
SahilTikale Jun 6, 2016
61bb87d
Adds files containing common code to build client library.
SahilTikale Jun 20, 2016
3d8ca6d
Merge branch 'master' into HILclientlib-querycalls
SahilTikale Jun 20, 2016
ee5aa40
Adds client library support for query calls
SahilTikale Jun 20, 2016
529b37c
Adds client support to CLI.
SahilTikale Jul 3, 2016
e5cdad3
Adds
SahilTikale Jul 5, 2016
060a55e
Adds unit tests and some code refactor.
SahilTikale Jul 5, 2016
5237d61
Addresses unit tests of client Base class
SahilTikale Jul 5, 2016
dc4ffea
Merge branch 'master' into HILclientlib-querycalls
SahilTikale Jul 5, 2016
cae9dd4
Supports new call list_nodes in place of list_free_nodes.
SahilTikale Jul 5, 2016
06b197a
adds __init__ file
SahilTikale Jul 25, 2016
f9eb580
making unit tests to work
SahilTikale Jul 26, 2016
2e63285
Includes a clean way to
SahilTikale Aug 8, 2016
f36ac1f
unit tests pass.
SahilTikale Aug 8, 2016
ddf43d4
Merge remote-tracking branch 'origin/master' into HILclientlib-queryc…
SahilTikale Aug 8, 2016
595c30d
Fixes unit tests
SahilTikale Aug 8, 2016
b0106ac
increasing delay to fix tests
SahilTikale Aug 8, 2016
27a619f
fixes CI test
SahilTikale Aug 10, 2016
e04d629
fixing CI tests
SahilTikale Aug 10, 2016
ae7c278
Merge remote-tracking branch 'origin/master' into HILclientlib-queryc…
SahilTikale Oct 11, 2016
7cddc95
Fixes call list_nodes in the client library. Had the same issue as fi…
SahilTikale Oct 11, 2016
ef94c61
Adding add/delete operations and tests related to project
SahilTikale Oct 11, 2016
e5f3150
Adding network module to client library
SahilTikale Oct 11, 2016
c07cc78
Adds client library support and unit tests for
SahilTikale Oct 12, 2016
16de104
Adds node operations.
SahilTikale Oct 17, 2016
404a37b
Adds
SahilTikale Oct 17, 2016
c3d54bf
syncing with upstream master
SahilTikale Nov 7, 2016
16bb93c
This commit makes the necessary changes to support keystone as a backend
SahilTikale Nov 9, 2016
da671fc
Removes old client Library
SahilTikale Nov 9, 2016
2e164cd
Fixes some broken tests. Makes tests/unit/client.py pep8 complaint.
SahilTikale Nov 9, 2016
e132ea6
1st pass at Integrating keystone authentication with client library.
SahilTikale Nov 9, 2016
485ced3
Adds user operations related calls in client library and cli.
SahilTikale Dec 11, 2016
b9ffe29
Adds client library calls for network, node and cli support for them.
SahilTikale Dec 12, 2016
ba23ded
Adds calls node connect network and switch related calls.
SahilTikale Dec 14, 2016
174cec7
minor changes
SahilTikale Dec 14, 2016
347090c
Adds client library calls for most of the api calls
SahilTikale Dec 22, 2016
bcbcd12
Fixes console calls in node.py and adds unit tests
SahilTikale Dec 22, 2016
37cf4b0
adds more unit tests
SahilTikale Dec 22, 2016
4d50af5
Merge branch 'master' into HILclientlib-querycalls
SahilTikale Dec 22, 2016
21f9d13
addresses @zenhacks comments
SahilTikale Dec 22, 2016
559bc40
fixed failing test
naved001 Jan 13, 2017
d65ed0f
fixed pep8 errors in all files except test/unit/client.py
meng-sun Jan 14, 2017
16bbefd
Merge remote-tracking branch 'upstream/HILclientlib-querycalls' into …
meng-sun Jan 14, 2017
bac7d39
pep8 issues fixed
gfaline Jan 17, 2017
5c29a76
Merge pull request #2 from meng-sun/HILclientlib-querycalls
gfaline Jan 17, 2017
98967cd
fixed a couple more pep8 errors
gfaline Jan 17, 2017
0556f3d
fixed pep8 issues
gfaline Jan 17, 2017
14cedef
Merge pull request #1 from naved001/HILclientlib-querycalls
henn Jan 18, 2017
7b6523e
type error fix that aligns with pep8 fix
meng-sun Jan 18, 2017
7fe634d
assertionError problems fixed
meng-sun Jan 19, 2017
0213717
Merge pull request #3 from meng-sun/HILclientlib-querycalls
meng-sun Jan 19, 2017
d1c9eba
Merge pull request #4 from naved001/naved/sahil
SahilTikale Jan 31, 2017
e22c210
Addresses comments from reviewers.
SahilTikale Feb 1, 2017
5e30397
fixing pep8 issues
SahilTikale Feb 1, 2017
b45ec80
Includes code refactored to reduce verbosity as recommended by @zenhack
SahilTikale Feb 16, 2017
d20c55f
removing non-essential code
SahilTikale Feb 16, 2017
adc94d0
removes import that is not required anymore
SahilTikale Feb 16, 2017
493ae42
Merge remote-tracking branch 'origin/master' into HILclientlib-queryc…
SahilTikale Feb 16, 2017
290e150
Refactors cli.py to reduce repetitive code
SahilTikale Feb 18, 2017
a54ce5e
Fixes the broken test due to recent merging with the master
SahilTikale Feb 19, 2017
b1b3e97
Fixes the broken test due to recent merging with the master
SahilTikale Feb 19, 2017
de9ddeb
Refactors client library code to reduce code verbosity.
SahilTikale Feb 19, 2017
d266f4d
Minor refactoring. moving to only for methods.
SahilTikale Feb 23, 2017
a8a0a71
Fixes tests
SahilTikale Feb 27, 2017
df915fd
Updates setup.py to install dependencies to support keystone.
SahilTikale Feb 28, 2017
e05786f
Makes changes suggested by @zenhack.
SahilTikale Feb 28, 2017
3b1ece8
Fixes doc string and other minor changes
SahilTikale Mar 1, 2017
8a33ed0
Merge branch 'master' into HILclientlib-querycalls
SahilTikale Mar 20, 2017
6a8b932
Changes client library to accept a complete object
SahilTikale Mar 20, 2017
42bd4dd
Fixes failing tests,
SahilTikale Mar 20, 2017
c7195a1
minor changes
SahilTikale Mar 20, 2017
67ba238
Fixes cli integration test, Puts appropriate comments in cli.py
SahilTikale Mar 22, 2017
f48e608
minor changes, moving text from docstring to comment
SahilTikale Mar 23, 2017
696f3ef
fixes integration tests
SahilTikale Mar 27, 2017
5786e37
Addresses all the changes recommended by reviewers.
SahilTikale Apr 2, 2017
b01e176
improves tests, removes redundant code
SahilTikale Apr 4, 2017
cca1c99
fixes a tedious test.
SahilTikale Apr 4, 2017
d6e0247
Updated with comment and increased time to avoid a potential race con…
SahilTikale Apr 5, 2017
82a9044
solves the race condition for network tests.
SahilTikale Apr 6, 2017
a1ff5b4
uses sqlalchemy to query networkingaction, to avoid race condition in…
SahilTikale Apr 10, 2017
1cd832e
refactors . Addresses other suggestions by reviewers.
SahilTikale Apr 14, 2017
22800ab
Improves tests, provides explicit message for time out. Moves imports…
SahilTikale Apr 18, 2017
157e518
minorly improves
SahilTikale Apr 20, 2017
922437f
Catches error of not setting HAAS_ENDPOINT.
SahilTikale Apr 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions tests/unit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
from urlparse import urljoin
import requests
from requests.exceptions import ConnectionError
from flask.ext.sqlalchemy import SQLAlchemy
from haas.flaskapp import app
from haas.model import NetworkingAction
from haas.client.base import ClientBase, FailedAPICallException
from haas.client.client import Client, RequestsHTTPClient, KeystoneHTTPClient


ep = "http://127.0.0.1:8000" or os.environ.get('HAAS_ENDPOINT')
username = "hil_user" or os.environ.get('HAAS_USERNAME')
password = "hil_pass1234" or os.environ.get('HAAS_PASSWORD')
Expand Down Expand Up @@ -71,7 +73,7 @@ def test_object_url(self):
def make_config():
""" This function creates haas.cfg with desired options
and writes to a temporary directory.
It returns a tuple where (tmpdir, cwd) = ('location of haas.cfg', 'pwdd')
It returns a tuple where (tmpdir, cwd) = ('location of haas.cfg', 'pwd')
"""
tmpdir = tempfile.mkdtemp()
global db_dir
Expand Down Expand Up @@ -248,21 +250,18 @@ def avoid_network_race_condition():
Used to avoid race condition between subsequent network calls
on the same object.
"""

from flask.ext.sqlalchemy import SQLAlchemy
from haas.flaskapp import app
from haas.model import Node, Project, NetworkingAction

global db_dir
uri = 'sqlite:///'+db_dir+'/haas.db'
db = SQLAlchemy(app)
app.config.update(SQLALCHEMY_DATABASE_URI=uri)

for timeout in range(10):
if (db.session.query(NetworkingAction).count() > 0):
que = db.session.query(NetworkingAction).count()
if (que > 0):
time.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should still put some upper bound on how long we're willing to wait -- maybe a minute or two. Otherwise travis will run for a very long time without notifying us that anything is wrong. I've had jobs just busy looping for 20 minutes before.

Doing an exponential backoff would be the "standard" approach, but I'm not picky on that point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

put a time out of 10 sec

else:
break
return que
return timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just raise an exception here (of a newly-declared type, which denotes a timeout), and get rid of the if/else checks elsewhere.



@pytest.fixture(scope="module")
Expand Down Expand Up @@ -355,15 +354,21 @@ def test_node_connect_network_error(self):

def test_node_detach_network(self):
C.node.connect_network('node-04', 'eth0', 'net-04', 'vlan/native')
avoid_network_race_condition()
assert C.node.detach_network('node-04', 'eth0', 'net-04') is None
x = avoid_network_race_condition()
if x == 0:
assert C.node.detach_network('node-04', 'eth0', 'net-04') is None
else:
assert False, "Timing out a race condition for networking actions."

def test_node_detach_network_error(self):
C.node.connect_network('node-04', 'eth0', 'net-04', 'vlan/native')
avoid_network_race_condition()
C.node.detach_network('node-04', 'eth0', 'net-04')
with pytest.raises(FailedAPICallException):
x = avoid_network_race_condition()
if x == 0:
C.node.detach_network('node-04', 'eth0', 'net-04')
with pytest.raises(FailedAPICallException):
C.node.detach_network('node-04', 'eth0', 'net-04')
else:
assert False, "Timing out a race condition for networking actions."


@pytest.mark.usefixtures("create_setup")
Expand Down