run_tests.sh restored
This commit is contained in:
parent
6b2e54eae6
commit
c7631173d4
@ -207,7 +207,6 @@ class ReleaseHandler(JSONHandler):
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ReleaseCollectionHandler(JSONHandler):
|
||||
def GET(self):
|
||||
web.header('Content-Type', 'application/json')
|
||||
|
80
nailgun/run_tests.sh
Executable file
80
nailgun/run_tests.sh
Executable file
@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: $0 [OPTION]..."
|
||||
echo "Run tests"
|
||||
echo ""
|
||||
echo " -p, --pep8 Just run PEP8 and HACKING compliance check"
|
||||
echo " -x, --xunit Generate reports (useful in Jenkins environment)"
|
||||
echo " -P, --no-pep8 Don't run static code checks"
|
||||
echo " -c, --clean Only clean *.log, *.json, *.pyc, *.pid files, doesn't run tests"
|
||||
echo " -h, --help Print this usage message"
|
||||
echo ""
|
||||
echo "By default it runs tests and pep8 check."
|
||||
exit
|
||||
}
|
||||
|
||||
function process_option {
|
||||
case "$1" in
|
||||
-h|--help) usage;;
|
||||
-p|--pep8) just_pep8=1;;
|
||||
-P|--no-pep8) no_pep8=1;;
|
||||
-x|--xunit) xunit=1;;
|
||||
-c|--clean) clean=1;;
|
||||
-*) noseopts="$noseopts $1";;
|
||||
*) noseargs="$noseargs $1"
|
||||
esac
|
||||
}
|
||||
|
||||
just_pep8=0
|
||||
no_pep8=0
|
||||
xunit=0
|
||||
clean=0
|
||||
noseargs=
|
||||
noseopts=
|
||||
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
|
||||
function clean {
|
||||
echo "cleaning *.pyc, *.json, *.log, *.pid files"
|
||||
find . -type f -name "*.pyc" -delete
|
||||
rm -f *.json
|
||||
rm -f *.log
|
||||
rm -f *.pid
|
||||
}
|
||||
|
||||
if [ $clean -eq 1 ]; then
|
||||
clean
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If enabled, tell nose to create xunit report
|
||||
if [ $xunit -eq 1 ]; then
|
||||
noseopts="--with-xunit"
|
||||
fi
|
||||
|
||||
function run_pep8 {
|
||||
pep8 --show-source --show-pep8 --count . || return 1
|
||||
echo "PEP8 check passed successfully."
|
||||
}
|
||||
|
||||
if [ $just_pep8 -eq 1 ]; then
|
||||
run_pep8 || exit 1
|
||||
exit
|
||||
fi
|
||||
|
||||
function run_tests {
|
||||
clean
|
||||
[ -z "$noseargs" ] && test_args=nailgun || test_args="$noseargs"
|
||||
python nailgun.py test $noseopts $test_args
|
||||
}
|
||||
|
||||
run_tests || exit 1
|
||||
|
||||
if [ -z "$noseargs" ]; then
|
||||
if [ $no_pep8 -eq 0 ]; then
|
||||
run_pep8
|
||||
fi
|
||||
fi
|
@ -5,6 +5,7 @@ import urllib2
|
||||
|
||||
from api.urls import urls
|
||||
|
||||
|
||||
class HTTPClient(object):
|
||||
def __init__(self):
|
||||
self.opener = urllib2.build_opener(urllib2.HTTPHandler)
|
||||
@ -45,5 +46,3 @@ def reverse(name, kwargs=None):
|
||||
url = re.sub(r"\(.+\)", str(kwargs[kwarg]), url, 1)
|
||||
url = re.sub(r"\??\$", "", url)
|
||||
return "/api" + url
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="23" errors="0" failures="0" skip="7"><testcase classname="test.test_handlers.TestHandlers" name="test_all_api_urls_404" time="0.718" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_creation" time="1.001" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_creation_pass" time="0.796" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_node_list_update" time="1.288" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_update" time="1.054" /><testcase classname="test.test_handlers.TestHandlers" name="test_network_create" time="0.000"><skipped type="unittest.case.SkipTest" message="obsolete"><![CDATA[SkipTest: obsolete
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation" time="0.805" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation_using_put" time="0.000"><skipped type="unittest.case.SkipTest" message="wth?"><![CDATA[SkipTest: wth?
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation_with_id" time="0.723" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_deletion" time="0.972" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_list_of_new_roles_gets_updated" time="0.921" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_metadata_gets_updated" time="0.916" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_status_gets_updated" time="1.018" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_interfaces_empty" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="23" errors="0" failures="0" skip="7"><testcase classname="test.test_handlers.TestHandlers" name="test_all_api_urls_404" time="0.718" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_creation" time="1.010" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_creation_pass" time="0.702" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_node_list_update" time="1.315" /><testcase classname="test.test_handlers.TestHandlers" name="test_cluster_update" time="0.970" /><testcase classname="test.test_handlers.TestHandlers" name="test_network_create" time="0.000"><skipped type="unittest.case.SkipTest" message="obsolete"><![CDATA[SkipTest: obsolete
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation" time="0.791" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation_using_put" time="0.000"><skipped type="unittest.case.SkipTest" message="wth?"><![CDATA[SkipTest: wth?
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_node_creation_with_id" time="0.815" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_deletion" time="0.885" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_list_of_new_roles_gets_updated" time="0.954" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_metadata_gets_updated" time="0.902" /><testcase classname="test.test_handlers.TestHandlers" name="test_node_valid_status_gets_updated" time="0.886" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_interfaces_empty" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_block_device_attr" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_body" time="0.808" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_cpu_attr" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_body" time="0.782" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_cpu_attr" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_interfaces_attr" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_no_memory_attr" time="0.000"><skipped type="unittest.case.SkipTest" message="no validation of metadata"><![CDATA[SkipTest: no validation of metadata
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_wrong_status" time="0.811" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_415_if_wrong_content_type" time="0.930" /><testcase classname="test.test_handlers.TestHandlers" name="test_release_create" time="0.830" /><testcase classname="test.test_handlers.TestHandlers" name="test_release_creation" time="0.855" /></testsuite>
|
||||
]]></skipped></testcase><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_400_if_wrong_status" time="0.872" /><testcase classname="test.test_handlers.TestHandlers" name="test_put_returns_415_if_wrong_content_type" time="0.791" /><testcase classname="test.test_handlers.TestHandlers" name="test_release_create" time="0.934" /><testcase classname="test.test_handlers.TestHandlers" name="test_release_creation" time="0.794" /></testsuite>
|
@ -172,7 +172,9 @@ class TestHandlers(TestCase):
|
||||
)
|
||||
self.db.refresh(cluster)
|
||||
self.assertEquals(resp.status, 200)
|
||||
clusters = self.db.query(Cluster).filter(Cluster.name == updated_name).all()
|
||||
clusters = self.db.query(Cluster).filter(
|
||||
Cluster.name == updated_name
|
||||
).all()
|
||||
self.assertEquals(len(clusters), 1)
|
||||
self.assertEquals(clusters[0].name, updated_name)
|
||||
|
||||
@ -204,7 +206,6 @@ class TestHandlers(TestCase):
|
||||
nodes = self.db.query(Node).filter(Node.cluster == cluster)
|
||||
self.assertEquals(2, nodes.count())
|
||||
|
||||
|
||||
def test_node_creation_with_id(self):
|
||||
node_id = '080000000003'
|
||||
resp = self.app.post(
|
||||
@ -227,7 +228,7 @@ class TestHandlers(TestCase):
|
||||
def test_node_deletion(self):
|
||||
node = self.create_default_node()
|
||||
resp = self.app.delete(
|
||||
reverse('NodeHandler', kwargs={'node_id':node.id}),
|
||||
reverse('NodeHandler', kwargs={'node_id': node.id}),
|
||||
"",
|
||||
headers=self.default_headers,
|
||||
expect_errors=True
|
||||
@ -257,7 +258,9 @@ class TestHandlers(TestCase):
|
||||
self.assertEquals(resp.status, 200)
|
||||
self.db.refresh(node)
|
||||
|
||||
nodes = self.db.query(Node).filter(Node.id == node.id).all()
|
||||
nodes = self.db.query(Node).filter(
|
||||
Node.id == node.id
|
||||
).all()
|
||||
self.assertEquals(len(nodes), 1)
|
||||
self.assertEquals(nodes[0].meta, new_metadata)
|
||||
|
||||
@ -282,7 +285,9 @@ class TestHandlers(TestCase):
|
||||
self.assertEquals(resp.status, 200)
|
||||
self.db.refresh(node)
|
||||
|
||||
node_from_db = self.db.query(Node).filter(Node.id==node.id).first()
|
||||
node_from_db = self.db.query(Node).filter(
|
||||
Node.id == node.id
|
||||
).first()
|
||||
self.assertEquals(node_from_db.redeployment_needed, True)
|
||||
|
||||
def test_put_returns_400_if_no_body(self):
|
||||
|
@ -19,4 +19,4 @@ class TestRunner(object):
|
||||
__file__,
|
||||
"--with-xunit",
|
||||
"--xunit-file=test/nosetests.xml"
|
||||
])
|
||||
])
|
||||
|
@ -6,4 +6,4 @@ from webui.urls import webui_app
|
||||
urls = (
|
||||
"/api", api_app,
|
||||
"/", webui_app
|
||||
)
|
||||
)
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
import web
|
||||
|
||||
|
||||
class IndexHandler(object):
|
||||
def GET(self):
|
||||
render = web.template.render('static/')
|
||||
return render.index()
|
||||
return render.index()
|
||||
|
@ -5,7 +5,7 @@ import web
|
||||
from webui.handlers import IndexHandler
|
||||
|
||||
urls = (
|
||||
r"", 'IndexHandler',
|
||||
r"", 'IndexHandler',
|
||||
)
|
||||
|
||||
webui_app = web.application(urls, locals())
|
||||
webui_app = web.application(urls, locals())
|
||||
|
Loading…
Reference in New Issue
Block a user