summaryrefslogtreecommitdiffstats
path: root/test-scheduler/server/src
diff options
context:
space:
mode:
authorLeoQi <QibinZheng2014@tongji.edu.cn>2018-09-20 09:38:01 +0800
committerLeoQi <QibinZheng2014@tongji.edu.cn>2018-09-20 13:50:35 +0800
commit399ec2f328f56c1f81c454ecedfb6b99eaf93c42 (patch)
tree6e7062c5cf9a387d7e98c4cee628d756db6f7e3f /test-scheduler/server/src
parent27d82af1145673330eddbe80eb39c47d93322cbe (diff)
fix testsuite name bugs and improve some ui details
JIRA: BOTTLENECK-247 fix the bug where the testsuite name contains Chinese characters. add license header automatically when a testcase created. ui improvements: workflow panel only turns up when a testcase executes. add grafana pages in the webpage 'Test Result'. add the highlight effect on the navigation item. Change-Id: If0ddf82fd4630128f2c4dd7fdde30f037e5bfba7 Signed-off-by: LeoQi <QibinZheng2014@tongji.edu.cn>
Diffstat (limited to 'test-scheduler/server/src')
-rw-r--r--test-scheduler/server/src/env/config/license8
-rw-r--r--test-scheduler/server/src/rest/router.py24
-rw-r--r--test-scheduler/server/src/test_parser.py7
3 files changed, 34 insertions, 5 deletions
diff --git a/test-scheduler/server/src/env/config/license b/test-scheduler/server/src/env/config/license
new file mode 100644
index 00000000..85d997a7
--- /dev/null
+++ b/test-scheduler/server/src/env/config/license
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/test-scheduler/server/src/rest/router.py b/test-scheduler/server/src/rest/router.py
index 1ceeedd0..b7752837 100644
--- a/test-scheduler/server/src/rest/router.py
+++ b/test-scheduler/server/src/rest/router.py
@@ -20,12 +20,12 @@ import traceback
import src.test_parser as test_parser
-
-BASE_DIR = os.path.abspath(os.path.dirname(__file__))
+BASE_DIR = unicode(os.path.abspath(os.path.dirname(__file__)), 'utf-8')
TESTSUITE_DIR = os.path.join(BASE_DIR, "..", "..", "test", "test_case")
SERVICE_DIR = os.path.join(BASE_DIR, "..", "env", "service")
CONTEXT_FILE_DIR = os.path.join(BASE_DIR, "..", "env", "context",
"context.yaml")
+CONFIG_DIR = os.path.join(BASE_DIR, "..", "env", "config")
app = Flask(__name__)
CORS(app)
@@ -198,8 +198,8 @@ def createTestcase():
"error": "testcase already exists!"})
casePath = os.path.join(exSuitePath, caseName)
with open(casePath, "w") as f:
- # the next line is a placeholder.
- print f
+ license_header = getLicense()
+ f.write(license_header)
else:
return jsonify({"code": 300, "error": "no such test suite!"})
except BaseException, e:
@@ -243,6 +243,8 @@ def saveTCContent():
casePath = os.path.join(TESTSUITE_DIR, casePath)
if os.path.exists(casePath):
with open(casePath, "w") as f:
+ license_header = getLicense()
+ f.write(license_header)
pyaml.dump(parseData, f, safe=True)
else:
return jsonify({"code": 300, "error": "no such file!"})
@@ -389,6 +391,8 @@ def createService():
serviceFile = name + '.yaml'
servicePath = os.path.join(SERVICE_DIR, serviceFile)
with open(servicePath, 'w') as f:
+ license_header = getLicense()
+ f.write(license_header)
pyaml.dump(service, f, safe=True)
except BaseException, e:
return returnServerError(e)
@@ -424,6 +428,8 @@ def editService():
serviceFile = name + '.yaml'
servicePath = os.path.join(SERVICE_DIR, serviceFile)
with open(servicePath, 'w') as f:
+ license_header = getLicense()
+ f.write(license_header)
pyaml.dump(service, f, safe=True)
except BaseException, e:
return returnServerError(e)
@@ -472,6 +478,16 @@ def editContext():
return returnServerError(e)
return jsonify({"code": 200, "result": "edit context success!"})
+
+
+def getLicense():
+ licenseDir = os.path.join(CONFIG_DIR, "license")
+ with open(licenseDir, 'r') as f:
+ content = f.read()
+ if content is None:
+ return ''
+ return content + '\n---\n\n'
+
###########################################################################
diff --git a/test-scheduler/server/src/test_parser.py b/test-scheduler/server/src/test_parser.py
index af0134a7..e4a426b1 100644
--- a/test-scheduler/server/src/test_parser.py
+++ b/test-scheduler/server/src/test_parser.py
@@ -44,7 +44,12 @@ def parse(filepath):
return workflowId
-def parseTestcase(schema, tcName='testcase0'):
+def parseTestcase(schema, tcName='testcase0.yaml'):
+ try:
+ tcName.decode('ascii')
+ except Exception, e:
+ print e
+ tcName = 'testcase0.yaml'
if schema is None:
return parseLog(False, reason='schema not found.')
steps = schema['steps']