Testing regression tool
- adding test: Delete app with routes - adjusting regression tool to work properly
This commit is contained in:
parent
d432b9363a
commit
7903c95ac6
|
@ -194,6 +194,15 @@ Testing: Integration
|
||||||
TBD
|
TBD
|
||||||
|
|
||||||
|
|
||||||
|
Testing: Coverage regression
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
In order to build quality software it is necessary to keep test coverage at its highest point.
|
||||||
|
So, as part of `Tox` testing new check was added - functional test coverage regression.
|
||||||
|
In order to run it use next command:
|
||||||
|
|
||||||
|
$ tox -e py35-functional-regression
|
||||||
|
|
||||||
3rd party bugs to resolve
|
3rd party bugs to resolve
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class AppV1Controller(controllers.ServiceControllerBase):
|
||||||
return web.json_response(data={
|
return web.json_response(data={
|
||||||
"error": {
|
"error": {
|
||||||
"message": ("App {} has routes, "
|
"message": ("App {} has routes, "
|
||||||
"delete them in first place")
|
"delete them in first place".format(app))
|
||||||
}
|
}
|
||||||
}, status=403)
|
}, status=403)
|
||||||
|
|
||||||
|
|
|
@ -60,3 +60,23 @@ class TestApps(base.LaosFunctionalTestsBase):
|
||||||
self.test_client.apps.delete("unknown"))
|
self.test_client.apps.delete("unknown"))
|
||||||
self.assertEqual(404, http_status)
|
self.assertEqual(404, http_status)
|
||||||
self.assertIn("error", json)
|
self.assertIn("error", json)
|
||||||
|
|
||||||
|
def test_delete_with_routes(self):
|
||||||
|
app_name = "testapp"
|
||||||
|
app, _ = self.testloop.run_until_complete(
|
||||||
|
self.test_client.apps.create(app_name))
|
||||||
|
self.testloop.run_until_complete(
|
||||||
|
self.test_client.routes.create(
|
||||||
|
app["app"]["name"], **self.route_data)
|
||||||
|
)
|
||||||
|
attempt, status = self.testloop.run_until_complete(
|
||||||
|
self.test_client.apps.delete(app["app"]["name"])
|
||||||
|
)
|
||||||
|
self.testloop.run_until_complete(
|
||||||
|
self.test_client.routes.delete(
|
||||||
|
app["app"]["name"], self.route_data["path"])
|
||||||
|
)
|
||||||
|
self.assertEqual(403, status)
|
||||||
|
self.assertIn("error", attempt)
|
||||||
|
self.assertIn("message", attempt["error"])
|
||||||
|
self.assertIn("has routes", attempt["error"]["message"])
|
||||||
|
|
|
@ -1,21 +1,29 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set +x
|
||||||
|
set +e
|
||||||
|
|
||||||
function get_current_coverage {
|
function get_current_coverage {
|
||||||
local prev_stat_raw=`TEST_DB_URI=${TEST_DB_URI} tox -e py35-functional | grep TOTAL | awk '{print $4}'`
|
local prev_stat_raw=`TEST_DB_URI=${TEST_DB_URI} pytest --tb=long --capture=sys --cov=laos --capture=fd laos/tests/functional | grep TOTAL | awk '{print $4}'`
|
||||||
echo ${prev_stat_raw:0:2}
|
echo ${prev_stat_raw:0:2}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_coverage_delta {
|
function get_coverage_delta {
|
||||||
local current_coverage=$(get_current_coverage)
|
local current_coverage=$(get_current_coverage)
|
||||||
local current_branch=`git branch | awk '{print $2}'`
|
local current_branch=`git branch | awk '{print $2}'`
|
||||||
git checkout `git rev-parse --verify HEAD^${1:-1}`
|
echo -e "Falling back to ${1} commits."
|
||||||
|
local commits=`seq -f "^" -s '' ${1:-1}`
|
||||||
|
git checkout `git rev-parse --verify HEAD${commits}` &> /dev/null
|
||||||
local prev_coverage=$(get_current_coverage)
|
local prev_coverage=$(get_current_coverage)
|
||||||
|
echo -e "Current coverage: ${current_coverage}%"
|
||||||
|
echo -e "Previous coverage: ${prev_coverage}%"
|
||||||
if [ "${prev_coverage}" -gt "${current_coverage}" ]; then
|
if [ "${prev_coverage}" -gt "${current_coverage}" ]; then
|
||||||
echo -e "Test regression found.\n Current commit: ${current_coverage} \Previous commit: ${prev_coverage}."
|
echo -e "Failed: test regression found.\n Current commit: ${current_coverage} \Previous commit: ${prev_coverage}."
|
||||||
git checkout ${current_branch}
|
git checkout ${current_branch}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
git checkout ${current_branch}
|
echo -e "Passed: regression not found."
|
||||||
|
git checkout ${current_branch} &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -31,6 +31,9 @@ commands = {posargs}
|
||||||
[testenv:py35-functional]
|
[testenv:py35-functional]
|
||||||
commands = pytest --tb=long --capture=sys --cov=laos --capture=fd {toxinidir}/laos/tests/functional
|
commands = pytest --tb=long --capture=sys --cov=laos --capture=fd {toxinidir}/laos/tests/functional
|
||||||
|
|
||||||
|
[testenv:py35-functional-regression]
|
||||||
|
commands = {toxinidir}/scripts/test_regression.sh {posargs}
|
||||||
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands =
|
commands =
|
||||||
|
|
Loading…
Reference in New Issue