summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jjb/dovetail/dovetail-ci-jobs.yml7
-rwxr-xr-xjjb/dovetail/dovetail-run.sh10
-rw-r--r--jjb/dovetail/dovetail-weekly-jobs.yml3
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py5
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py57
5 files changed, 67 insertions, 15 deletions
diff --git a/jjb/dovetail/dovetail-ci-jobs.yml b/jjb/dovetail/dovetail-ci-jobs.yml
index 0bd32a4ab..b65e6d5ef 100644
--- a/jjb/dovetail/dovetail-ci-jobs.yml
+++ b/jjb/dovetail/dovetail-ci-jobs.yml
@@ -208,15 +208,18 @@
- 'dovetail-cleanup'
- 'dovetail-run'
+ wrappers:
+ - fix-workspace-permissions
+
publishers:
- archive:
artifacts: 'results/**/*'
allow-empty: true
fingerprint: true
-########################
+#--------------------------
# builder macros
-########################
+#--------------------------
- builder:
name: dovetail-run
builders:
diff --git a/jjb/dovetail/dovetail-run.sh b/jjb/dovetail/dovetail-run.sh
index 4b00ec881..5161a3c7c 100755
--- a/jjb/dovetail/dovetail-run.sh
+++ b/jjb/dovetail/dovetail-run.sh
@@ -85,11 +85,11 @@ echo "Container exec command: ${run_cmd}"
docker exec $container_id ${run_cmd}
sudo cp -r ${DOVETAIL_REPO_DIR}/results ./
-#To make sure the file owner is the current user, for the copied results files in the above line
-#if not, there will be error when next time to wipe workspace
-CURRENT_USER=${SUDO_USER:-$USER}
-PRIMARY_GROUP=$(id -gn $CURRENT_USER)
-sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
+# To make sure the file owner is the current user, for the copied results files in the above line
+# if not, there will be error when next time to wipe workspace
+# CURRENT_USER=${SUDO_USER:-$USER}
+# PRIMARY_GROUP=$(id -gn $CURRENT_USER)
+# sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
echo "Dovetail: done!"
diff --git a/jjb/dovetail/dovetail-weekly-jobs.yml b/jjb/dovetail/dovetail-weekly-jobs.yml
index 8edce4246..7b3ede902 100644
--- a/jjb/dovetail/dovetail-weekly-jobs.yml
+++ b/jjb/dovetail/dovetail-weekly-jobs.yml
@@ -114,6 +114,9 @@
- 'dovetail-cleanup'
- 'dovetail-run'
+ wrappers:
+ - fix-workspace-permissions
+
publishers:
- archive:
artifacts: 'results/**/*'
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index 4c31a6f0f..80eb1aabe 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -1,5 +1,7 @@
import functools
+from tornado import web
+
from opnfv_testapi.common import constants
from opnfv_testapi.resources import handlers
import opnfv_testapi.resources.scenario_models as models
@@ -182,6 +184,9 @@ class ScenarioGURHandler(GenericScenarioHandler):
def _update_requests_rename(self, data):
data.name = self._term.get('name')
+ if not data.name:
+ raise web.HTTPError(constants.HTTP_BAD_REQUEST,
+ "new scenario name is not provided")
def _update_requests_add_installer(self, data):
data.installers.append(models.ScenarioInstaller.from_dict(self._term))
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py
index a5a4fb30f..b62c1d294 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py
@@ -139,6 +139,7 @@ class TestScenarioUpdate(TestScenarioBase):
def setUp(self):
super(TestScenarioUpdate, self).setUp()
self.scenario = self.create_return_name(self.req_d)
+ self.scenario_2 = self.create_return_name(self.req_2)
def _execute(set_update):
@functools.wraps(set_update)
@@ -147,15 +148,45 @@ class TestScenarioUpdate(TestScenarioBase):
self._update_and_assert(update, scenario)
return magic
- def test_renameScenario(self):
+ def _update(expected):
+ def _update(set_update):
+ @functools.wraps(set_update)
+ def wrap(self):
+ update, scenario = set_update(self, deepcopy(self.req_d))
+ code, body = self.update(update, self.scenario)
+ getattr(self, expected)(code, scenario)
+ return wrap
+ return _update
+
+ @_update('_success')
+ def test_renameScenario(self, scenario):
new_name = 'nosdn-nofeature-noha'
- new_scenario = deepcopy(self.req_d)
- new_scenario['name'] = new_name
+ scenario['name'] = new_name
+ update_req = models.ScenarioUpdateRequest(field='name',
+ op='update',
+ locate={},
+ term={'name': new_name})
+ return update_req, scenario
+
+ @_update('_forbidden')
+ def test_renameScenario_exist(self, scenario):
+ new_name = self.scenario_2
+ scenario['name'] = new_name
update_req = models.ScenarioUpdateRequest(field='name',
op='update',
locate={},
term={'name': new_name})
- self._update_and_assert(update_req, new_scenario, new_name)
+ return update_req, scenario
+
+ @_update('_bad_request')
+ def test_renameScenario_noName(self, scenario):
+ new_name = self.scenario_2
+ scenario['name'] = new_name
+ update_req = models.ScenarioUpdateRequest(field='name',
+ op='update',
+ locate={},
+ term={})
+ return update_req, scenario
@_execute
def test_addInstaller(self, scenario):
@@ -297,12 +328,18 @@ class TestScenarioUpdate(TestScenarioBase):
def _update_and_assert(self, update_req, new_scenario, name=None):
code, _ = self.update(update_req, self.scenario)
self.assertEqual(code, constants.HTTP_OK)
- self._get_and_assert(self._none_default(name, self.scenario),
+ self._get_and_assert(_none_default(name, self.scenario),
new_scenario)
- @staticmethod
- def _none_default(check, default):
- return check if check else default
+ def _success(self, status, new_scenario):
+ self.assertEqual(status, constants.HTTP_OK)
+ self._get_and_assert(new_scenario.get('name'), new_scenario)
+
+ def _forbidden(self, status, new_scenario):
+ self.assertEqual(status, constants.HTTP_FORBIDDEN)
+
+ def _bad_request(self, status, new_scenario):
+ self.assertEqual(status, constants.HTTP_BAD_REQUEST)
class TestScenarioDelete(TestScenarioBase):
@@ -316,3 +353,7 @@ class TestScenarioDelete(TestScenarioBase):
self.assertEqual(code, constants.HTTP_OK)
code, _ = self.get(scenario)
self.assertEqual(code, constants.HTTP_NOT_FOUND)
+
+
+def _none_default(check, default):
+ return check if check else default