diff options
55 files changed, 561 insertions, 225 deletions
@@ -22,6 +22,7 @@ Mei Mei (Huawei, meimei@huawei.com) Trevor Bramwell (Linux Foundation, tbramwell@linuxfoundation.org) Serena Feng (ZTE, feng.xiaowei@zte.com.cn) Yolanda Robla Mota (Red Hat, yroblamo@redhat.com) +Markos Chandras (SUSE, mchandras@suse.de) Link to TSC approval of the project: http://ircbot.wl.linuxfoundation.org/meetings/opnfv-meeting/2015/opnfv-meeting.2015-07-14-14.00.html Link to TSC voting for removal of Victor Laza as committer: http://meetbot.opnfv.org/meetings/opnfv-meeting/2016/opnfv-meeting.2016-02-16-14.59.html diff --git a/jjb/3rd_party_ci/odl-netvirt.yml b/jjb/3rd_party_ci/odl-netvirt.yml index 054761ea7..0e479cc08 100644 --- a/jjb/3rd_party_ci/odl-netvirt.yml +++ b/jjb/3rd_party_ci/odl-netvirt.yml @@ -41,6 +41,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 5 @@ -150,6 +151,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 5 diff --git a/jjb/apex/apex.yml b/jjb/apex/apex.yml index 5c1bded4c..710a5f42c 100644 --- a/jjb/apex/apex.yml +++ b/jjb/apex/apex.yml @@ -93,6 +93,7 @@ - compare-type: ANT pattern: 'tests/**' properties: + - logrotate-default - throttle: max-per-node: 1 max-total: 10 @@ -154,6 +155,7 @@ pattern: 'config/**' properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -228,6 +230,7 @@ - git-scm properties: + - logrotate-default - build-blocker: use-build-blocker: true blocking-jobs: @@ -285,6 +288,7 @@ - git-scm properties: + - logrotate-default - build-blocker: use-build-blocker: false block-level: 'NODE' @@ -340,6 +344,7 @@ - git-scm properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -396,6 +401,7 @@ description: "Use yes in lower case to invoke clean. Indicates if the deploy environment should be cleaned before deployment" properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -438,6 +444,7 @@ description: "Scenario to deploy with." properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -476,6 +483,7 @@ gs-pathname: '{gs-pathname}' properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -588,6 +596,7 @@ - git-scm properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -632,6 +641,7 @@ description: "Scenario to deploy with." properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' @@ -670,6 +680,7 @@ gs-pathname: '/colorado' properties: + - logrotate-default - build-blocker: use-build-blocker: true block-level: 'NODE' diff --git a/jjb/armband/armband-ci-jobs.yml b/jjb/armband/armband-ci-jobs.yml index 4e88678b4..599a55ea5 100644 --- a/jjb/armband/armband-ci-jobs.yml +++ b/jjb/armband/armband-ci-jobs.yml @@ -104,6 +104,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -188,6 +189,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 diff --git a/jjb/armband/armband-project-jobs.yml b/jjb/armband/armband-project-jobs.yml index 981f509c7..2a1854937 100644 --- a/jjb/armband/armband-project-jobs.yml +++ b/jjb/armband/armband-project-jobs.yml @@ -30,6 +30,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 1 diff --git a/jjb/armband/armband-verify-jobs.yml b/jjb/armband/armband-verify-jobs.yml index d5333eb07..06ded3788 100644 --- a/jjb/armband/armband-verify-jobs.yml +++ b/jjb/armband/armband-verify-jobs.yml @@ -47,6 +47,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -167,6 +168,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 6 diff --git a/jjb/barometer/barometer.yml b/jjb/barometer/barometer.yml index e789b7f7a..7a5b5e43d 100644 --- a/jjb/barometer/barometer.yml +++ b/jjb/barometer/barometer.yml @@ -77,6 +77,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 3 @@ -128,6 +129,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 3 diff --git a/jjb/bottlenecks/bottlenecks-project-jobs.yml b/jjb/bottlenecks/bottlenecks-project-jobs.yml index 03e40dc0e..80a972bbe 100644 --- a/jjb/bottlenecks/bottlenecks-project-jobs.yml +++ b/jjb/bottlenecks/bottlenecks-project-jobs.yml @@ -114,6 +114,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 diff --git a/jjb/compass4nfv/compass-ci-jobs.yml b/jjb/compass4nfv/compass-ci-jobs.yml index 8800a155f..754b24edd 100644 --- a/jjb/compass4nfv/compass-ci-jobs.yml +++ b/jjb/compass4nfv/compass-ci-jobs.yml @@ -87,6 +87,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 @@ -173,6 +174,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/compass4nfv/compass-project-jobs.yml b/jjb/compass4nfv/compass-project-jobs.yml index 6b4080384..75ebdb206 100644 --- a/jjb/compass4nfv/compass-project-jobs.yml +++ b/jjb/compass4nfv/compass-project-jobs.yml @@ -33,6 +33,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 @@ -76,6 +77,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 diff --git a/jjb/compass4nfv/compass-verify-jobs.yml b/jjb/compass4nfv/compass-verify-jobs.yml index 6ef5fbb67..f5a54c8d9 100644 --- a/jjb/compass4nfv/compass-verify-jobs.yml +++ b/jjb/compass4nfv/compass-verify-jobs.yml @@ -22,6 +22,10 @@ disabled: false os-version: 'xenial' openstack-os-version: '' + - 'centos7': + disabled: false + os-version: 'centos7' + openstack-os-version: '' ##################################### # patch verification phases ##################################### @@ -47,6 +51,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -159,6 +164,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 @@ -240,3 +246,4 @@ name: COMPASS_OS_VERSION choices: - 'xenial' + - 'centos7' diff --git a/jjb/cperf/cperf-ci-jobs.yml b/jjb/cperf/cperf-ci-jobs.yml index 4ffc3b013..998e3c9c8 100644 --- a/jjb/cperf/cperf-ci-jobs.yml +++ b/jjb/cperf/cperf-ci-jobs.yml @@ -42,6 +42,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/daisy4nfv/daisy4nfv-merge-jobs.yml b/jjb/daisy4nfv/daisy4nfv-merge-jobs.yml index b7a5fec92..d84e46f3e 100644 --- a/jjb/daisy4nfv/daisy4nfv-merge-jobs.yml +++ b/jjb/daisy4nfv/daisy4nfv-merge-jobs.yml @@ -43,6 +43,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -166,6 +167,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 6 diff --git a/jjb/daisy4nfv/daisy4nfv-verify-jobs.yml b/jjb/daisy4nfv/daisy4nfv-verify-jobs.yml index cba22643c..82532b2b8 100644 --- a/jjb/daisy4nfv/daisy4nfv-verify-jobs.yml +++ b/jjb/daisy4nfv/daisy4nfv-verify-jobs.yml @@ -41,6 +41,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -156,6 +157,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 6 diff --git a/jjb/doctor/doctor.yml b/jjb/doctor/doctor.yml index ab9ef8f6c..62f89e686 100644 --- a/jjb/doctor/doctor.yml +++ b/jjb/doctor/doctor.yml @@ -24,10 +24,17 @@ - 'sample' - 'congress' + task: + - verify: + profiler: 'none' + auto-trigger-name: 'doctor-verify' + - profiling: + profiler: 'poc' + auto-trigger-name: 'experimental' + jobs: - 'doctor-verify-{stream}' - - 'doctor-verify-{installer}-{inspector}-{stream}' - - 'doctor-profiling-{stream}' + - 'doctor-{task}-{installer}-{inspector}-{stream}': - job-template: name: 'doctor-verify-{stream}' @@ -71,7 +78,7 @@ - shell: "[ -e tests/run.sh ] && bash -n ./tests/run.sh" - job-template: - name: 'doctor-verify-{installer}-{inspector}-{stream}' + name: 'doctor-{task}-{installer}-{inspector}-{stream}' node: '{slave-label}' @@ -107,7 +114,7 @@ default: '{project}' - string: name: TESTCASE_OPTIONS - default: '-e INSPECTOR_TYPE={inspector} -v $WORKSPACE:/home/opnfv/repos/doctor' + default: '-e INSPECTOR_TYPE={inspector} -e PROFILER_TYPE={profiler} -v $WORKSPACE:/home/opnfv/repos/doctor' description: 'Addtional parameters specific to test case(s)' # functest-parameter - string: @@ -131,32 +138,9 @@ - git-scm-gerrit triggers: - - gerrit: - server-name: 'gerrit.opnfv.org' - trigger-on: - - patchset-created-event: - exclude-drafts: 'false' - exclude-trivial-rebase: 'false' - exclude-no-code-change: 'false' - - draft-published-event - - comment-added-contains-event: - comment-contains-value: 'recheck' - - comment-added-contains-event: - comment-contains-value: 'reverify' - projects: - - project-compare-type: 'ANT' - project-pattern: '{project}' - branches: - - branch-compare-type: 'ANT' - branch-pattern: '**/{branch}' - file-paths: - - compare-type: ANT - pattern: 'tests/**' - skip-vote: - successful: true - failed: true - unstable: true - notbuilt: true + - '{auto-trigger-name}': + project: '{project}' + branch: '{branch}' builders: - 'functest-suite-builder' @@ -172,65 +156,36 @@ - archive: artifacts: 'tests/*.log' -- job-template: - name: 'doctor-profiling-{stream}' - - disabled: '{obj:disabled}' - - parameters: - - 'doctor-defaults': - project: '{project}' - branch: '{branch}' - - string: - name: PROFILER - default: poc - description: "Profiler to be used" - - scm: - - git-scm-gerrit - - triggers: - - 'experimental': - project: '{project}' - branch: '{branch}' - -##################################### -# parameter macros -##################################### -# TODO(yujunz) replace common parameter in doctor-verify-{stream} with macro -- parameter: - name: 'doctor-defaults' - parameters: - - project-parameter: - project: '{project}' - - gerrit-parameter: - branch: '{branch}' - - 'opnfv-build-ubuntu-defaults' ##################################### # trigger macros ##################################### -# TODO(yujunz) move to opnfv commom - trigger: - name: 'experimental' + name: 'doctor-verify' triggers: - gerrit: server-name: 'gerrit.opnfv.org' trigger-on: + - patchset-created-event: + exclude-drafts: 'false' + exclude-trivial-rebase: 'false' + exclude-no-code-change: 'false' + - draft-published-event + - comment-added-contains-event: + comment-contains-value: 'recheck' - comment-added-contains-event: - comment-contains-value: 'check-experimental' + comment-contains-value: 'reverify' projects: - - project-compare-type: 'ANT' - project-pattern: '{project}' - branches: - - branch-compare-type: 'ANT' - branch-pattern: '**/{branch}' - file-paths: - - compare-type: 'ANT' - pattern: 'tests/**' + - project-compare-type: 'ANT' + project-pattern: '{project}' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**/{branch}' + file-paths: + - compare-type: ANT + pattern: 'tests/**' skip-vote: successful: true failed: true unstable: true notbuilt: true - silent-start: true diff --git a/jjb/dovetail/dovetail-artifacts-upload.yml b/jjb/dovetail/dovetail-artifacts-upload.yml index dc2ae5aa2..1a6935646 100644 --- a/jjb/dovetail/dovetail-artifacts-upload.yml +++ b/jjb/dovetail/dovetail-artifacts-upload.yml @@ -33,6 +33,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 diff --git a/jjb/dovetail/dovetail-ci-jobs.yml b/jjb/dovetail/dovetail-ci-jobs.yml index 08eb5a5f1..917856beb 100644 --- a/jjb/dovetail/dovetail-ci-jobs.yml +++ b/jjb/dovetail/dovetail-ci-jobs.yml @@ -161,6 +161,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/escalator/escalator.yml b/jjb/escalator/escalator.yml index 4149ee93c..31e0c0004 100644 --- a/jjb/escalator/escalator.yml +++ b/jjb/escalator/escalator.yml @@ -39,6 +39,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -158,6 +159,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 diff --git a/jjb/fuel/fuel-daily-jobs.yml b/jjb/fuel/fuel-daily-jobs.yml index cd22c1ac2..02fa9fbf4 100644 --- a/jjb/fuel/fuel-daily-jobs.yml +++ b/jjb/fuel/fuel-daily-jobs.yml @@ -116,6 +116,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -191,6 +192,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 diff --git a/jjb/fuel/fuel-project-jobs.yml b/jjb/fuel/fuel-project-jobs.yml index 731b9bd0d..deab3ab21 100644 --- a/jjb/fuel/fuel-project-jobs.yml +++ b/jjb/fuel/fuel-project-jobs.yml @@ -35,6 +35,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 1 @@ -146,6 +147,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 2 @@ -219,6 +221,7 @@ disabled: '{obj:disabled}' properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/fuel/fuel-verify-jobs-experimental.yml b/jjb/fuel/fuel-verify-jobs-experimental.yml index 3aa85b22d..95d675ada 100644 --- a/jjb/fuel/fuel-verify-jobs-experimental.yml +++ b/jjb/fuel/fuel-verify-jobs-experimental.yml @@ -52,6 +52,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -174,6 +175,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 6 diff --git a/jjb/fuel/fuel-verify-jobs.yml b/jjb/fuel/fuel-verify-jobs.yml index c5f913e49..439489715 100644 --- a/jjb/fuel/fuel-verify-jobs.yml +++ b/jjb/fuel/fuel-verify-jobs.yml @@ -47,6 +47,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -169,6 +170,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 6 diff --git a/jjb/functest/functest-ci-jobs.yml b/jjb/functest/functest-ci-jobs.yml index 4920bffea..a688cab29 100644 --- a/jjb/functest/functest-ci-jobs.yml +++ b/jjb/functest/functest-ci-jobs.yml @@ -204,6 +204,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/global/releng-defaults.yml b/jjb/global/releng-defaults.yml index 5003a8f48..283888603 100644 --- a/jjb/global/releng-defaults.yml +++ b/jjb/global/releng-defaults.yml @@ -3,15 +3,12 @@ - defaults: name: global - logrotate: - daysToKeep: 60 - numToKeep: 200 - artifactDaysToKeep: 30 - artifactNumToKeep: 100 - wrappers: - ssh-agent-wrapper project-type: freestyle node: master + + properties: + - logrotate-default diff --git a/jjb/global/releng-macros.yml b/jjb/global/releng-macros.yml index 10835f6a3..d43bed77a 100644 --- a/jjb/global/releng-macros.yml +++ b/jjb/global/releng-macros.yml @@ -35,6 +35,15 @@ default: '{branch}' description: "JJB configured GERRIT_BRANCH parameter" +- property: + name: logrotate-default + properties: + - build-discarder: + days-to-keep: 60 + num-to-keep: 200 + artifact-days-to-keep: 60 + artifact-num-to-keep: 200 + - scm: name: git-scm scm: @@ -96,6 +105,30 @@ - branch-compare-type: 'ANT' branch-pattern: '**/{branch}' +- trigger: + name: 'experimental' + triggers: + - gerrit: + server-name: 'gerrit.opnfv.org' + trigger-on: + - comment-added-contains-event: + comment-contains-value: 'check-experimental' + projects: + - project-compare-type: 'ANT' + project-pattern: '{project}' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**/{branch}' + file-paths: + - compare-type: 'ANT' + pattern: 'tests/**' + skip-vote: + successful: true + failed: true + unstable: true + notbuilt: true + silent-start: true + - wrapper: name: ssh-agent-wrapper wrappers: diff --git a/jjb/infra/bifrost-upload-logs.sh b/jjb/infra/bifrost-upload-logs.sh deleted file mode 100755 index 8e1982dff..000000000 --- a/jjb/infra/bifrost-upload-logs.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2016 SUSE. -# 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 -############################################################################## - -set -eu -set -o pipefail - -BIFROST_CONSOLE_LOG="${BUILD_URL}/consoleText" -BIFROST_GS_URL=${BIFROST_LOG_URL/http:/gs:} -BIFROST_COMPRESS_SUFFIX="tar.gz" -BIFROST_COMPRESSED_LOGS=() - -echo "Uploading build logs to ${BIFROST_LOG_URL}" - -echo "Uploading console output" -curl -L ${BIFROST_CONSOLE_LOG} | gsutil cp - ${BIFROST_GS_URL}/build_log.txt - -[[ ! -d ${WORKSPACE}/logs ]] && exit 0 - -pushd ${WORKSPACE}/logs/ &> /dev/null -for x in *.log; do - echo "Compressing and uploading $x" - tar -czf - $x | gsutil cp - ${BIFROST_GS_URL}/${x}.${BIFROST_COMPRESS_SUFFIX} 1>/dev/null - BIFROST_COMPRESSED_LOGS+=(${x}.${BIFROST_COMPRESS_SUFFIX}) -done -popd &> /dev/null - -echo "Generating the landing page" -cat > index.html << EOF -<html> -<h1>Build results for <a href=https://$GERRIT_NAME/#/c/$GERRIT_CHANGE_NUMBER>$GERRIT_NAME/$GERRIT_CHANGE_NUMBER</a></h1> -<h2>Job: $JOB_NAME</h2> -<ul> -<li><a href=${BIFROST_LOG_URL}/build_log.txt>build_log.txt</a></li> -EOF - -for x in ${BIFROST_COMPRESSED_LOGS[@]}; do - echo "<li><a href=${BIFROST_LOG_URL}/${x}>${x}</a></li>" >> index.html -done - -cat >> index.html << EOF -</ul> -</html> -EOF - -gsutil cp index.html ${BIFROST_GS_URL}/index.html diff --git a/jjb/infra/bifrost-verify-jobs.yml b/jjb/infra/bifrost-verify-jobs.yml index 6232859ee..28e36aac6 100644 --- a/jjb/infra/bifrost-verify-jobs.yml +++ b/jjb/infra/bifrost-verify-jobs.yml @@ -74,6 +74,7 @@ concurrent: false properties: + - logrotate-default - build-blocker: use-build-blocker: true blocking-jobs: @@ -142,7 +143,6 @@ builders: - bifrost-set-name - bifrost-build - - bifrost-artifacts-upload publishers: - email: @@ -220,9 +220,3 @@ builders: - shell: !include-raw: ./bifrost-verify.sh - -- builder: - name: bifrost-artifacts-upload - builders: - - shell: - !include-raw: ./bifrost-upload-logs.sh diff --git a/jjb/infra/bifrost-verify.sh b/jjb/infra/bifrost-verify.sh index 9fbb1d0d9..dbe39762c 100755 --- a/jjb/infra/bifrost-verify.sh +++ b/jjb/infra/bifrost-verify.sh @@ -11,7 +11,51 @@ set -o errexit set -o nounset set -o pipefail -trap fix_ownership EXIT +trap cleanup_and_upload EXIT + +function upload_logs() { + BIFROST_CONSOLE_LOG="${BUILD_URL}/consoleText" + BIFROST_GS_URL=${BIFROST_LOG_URL/http:/gs:} + + echo "Uploading build logs to ${BIFROST_LOG_URL}" + + echo "Uploading console output" + curl -s -L ${BIFROST_CONSOLE_LOG} > ${WORKSPACE}/build_log.txt + gsutil -q cp -Z ${WORKSPACE}/build_log.txt ${BIFROST_GS_URL}/build_log.txt + rm ${WORKSPACE}/build_log.txt + + [[ ! -d ${WORKSPACE}/logs ]] && exit 0 + + pushd ${WORKSPACE}/logs/ &> /dev/null + for x in *.log; do + echo "Compressing and uploading $x" + gsutil -q cp -Z ${x} ${BIFROST_GS_URL}/${x} + done + + echo "Generating the landing page" + cat > index.html <<EOF +<html> +<h1>Build results for <a href=https://$GERRIT_NAME/#/c/$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER>$GERRIT_NAME/$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER</a></h1> +<h2>Job: $JOB_NAME</h2> +<ul> +<li><a href=${BIFROST_LOG_URL}/build_log.txt>build_log.txt</a></li> +EOF + + for x in *.log; do + echo "<li><a href=${BIFROST_LOG_URL}/${x}>${x}</a></li>" >> index.html + done + + cat >> index.html << EOF +</ul> +</html> +EOF + + gsutil -q cp index.html ${BIFROST_GS_URL}/index.html + + rm index.html + + popd &> /dev/null +} function fix_ownership() { if [ -z "${JOB_URL+x}" ]; then @@ -25,6 +69,13 @@ function fix_ownership() { fi } +function cleanup_and_upload() { + original_exit=$? + fix_ownership + upload_logs + exit $original_exit +} + # check distro to see if we support it if [[ ! "$DISTRO" =~ (trusty|centos7|suse) ]]; then echo "Distro $DISTRO is not supported!" diff --git a/jjb/joid/joid-daily-jobs.yml b/jjb/joid/joid-daily-jobs.yml index 9766f0339..ad1a76f0a 100644 --- a/jjb/joid/joid-daily-jobs.yml +++ b/jjb/joid/joid-daily-jobs.yml @@ -92,6 +92,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -161,6 +162,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 diff --git a/jjb/joid/joid-verify-jobs.yml b/jjb/joid/joid-verify-jobs.yml index 6e821a502..23e21e95b 100644 --- a/jjb/joid/joid-verify-jobs.yml +++ b/jjb/joid/joid-verify-jobs.yml @@ -45,6 +45,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 @@ -150,6 +151,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 4 diff --git a/jjb/kvmfornfv/kvmfornfv.yml b/jjb/kvmfornfv/kvmfornfv.yml index 60f8de8c4..fdce301a4 100644 --- a/jjb/kvmfornfv/kvmfornfv.yml +++ b/jjb/kvmfornfv/kvmfornfv.yml @@ -48,6 +48,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 3 diff --git a/jjb/opera/opera-daily-jobs.yml b/jjb/opera/opera-daily-jobs.yml index 556d59fcb..76aeb741e 100644 --- a/jjb/opera/opera-daily-jobs.yml +++ b/jjb/opera/opera-daily-jobs.yml @@ -38,6 +38,7 @@ concurrent: false properties: + - logrotate-default - throttle: enabled: true max-total: 1 @@ -105,6 +106,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/opera/opera-project-jobs.yml b/jjb/opera/opera-project-jobs.yml index 19f066b5f..19c9a881e 100644 --- a/jjb/opera/opera-project-jobs.yml +++ b/jjb/opera/opera-project-jobs.yml @@ -21,6 +21,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 diff --git a/jjb/opera/opera-verify-jobs.yml b/jjb/opera/opera-verify-jobs.yml index 0e9dba01d..d936cde9b 100644 --- a/jjb/opera/opera-verify-jobs.yml +++ b/jjb/opera/opera-verify-jobs.yml @@ -38,6 +38,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-total: 1 @@ -117,6 +118,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/jjb/releng/testapi-automate.yml b/jjb/releng/testapi-automate.yml index 552c25fe4..25ee687e2 100644 --- a/jjb/releng/testapi-automate.yml +++ b/jjb/releng/testapi-automate.yml @@ -18,6 +18,7 @@ project: '{project}' - gerrit-parameter: branch: '{branch}' + - 'opnfv-build-ubuntu-defaults' scm: - git-scm @@ -48,6 +49,25 @@ builders: - run-unit-tests + publishers: + - junit: + results: nosetests.xml + - cobertura: + report-file: "coverage.xml" + only-stable: "true" + health-auto-update: "true" + stability-auto-update: "true" + zoom-coverage-chart: "true" + targets: + - files: + healthy: 10 + unhealthy: 20 + failing: 30 + - method: + healthy: 50 + unhealthy: 40 + failing: 30 + - job-template: name: 'testapi-automate-{stream}' @@ -97,7 +117,7 @@ name: run-unit-tests builders: - shell: | - bash ./jjb/releng/testapi-run-tests.sh + bash ./utils/test/testapi/run_test.sh - builder: name: docker-update diff --git a/jjb/releng/testapi-run-tests.sh b/jjb/releng/testapi-run-tests.sh deleted file mode 100644 index 47691ed04..000000000 --- a/jjb/releng/testapi-run-tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -o errexit - -echo "Running unit tests..." - -# Creating virtual environment -virtualenv $WORKSPACE/testapi_test_venv -source $WORKSPACE/testapi_test_venv/bin/activate - -cd $WORKSPACE/utils/test/testapi/ - -# Install requirements -pip install -r requirements.txt -pip install -r test-requirements.txt - -# Run unit tests -bash run_test.sh diff --git a/jjb/vswitchperf/vswitchperf.yml b/jjb/vswitchperf/vswitchperf.yml index 4cfe5d98f..50937bbe0 100644 --- a/jjb/vswitchperf/vswitchperf.yml +++ b/jjb/vswitchperf/vswitchperf.yml @@ -62,6 +62,7 @@ concurrent: true properties: + - logrotate-default - build-blocker: use-build-blocker: true blocking-jobs: @@ -123,6 +124,7 @@ concurrent: true properties: + - logrotate-default - build-blocker: use-build-blocker: true blocking-jobs: diff --git a/jjb/yardstick/yardstick-ci-jobs.yml b/jjb/yardstick/yardstick-ci-jobs.yml index ed2dccab8..709592a89 100644 --- a/jjb/yardstick/yardstick-ci-jobs.yml +++ b/jjb/yardstick/yardstick-ci-jobs.yml @@ -220,6 +220,7 @@ concurrent: true properties: + - logrotate-default - throttle: enabled: true max-per-node: 1 diff --git a/utils/push-test-logs.sh b/utils/push-test-logs.sh index 61a6c327d..265ca6120 100644 --- a/utils/push-test-logs.sh +++ b/utils/push-test-logs.sh @@ -23,7 +23,7 @@ dir_result="${HOME}/opnfv/$project/results/${branch}" node_list=(\ 'lf-pod1' 'lf-pod2' 'intel-pod2' 'intel-pod3' \ 'intel-pod5' 'intel-pod6' 'intel-pod7' 'intel-pod8' \ -'ericsson-pod2' 'ericsson-pod3' 'ericsson-pod4' \ +'ericsson-pod1' 'ericsson-pod2' \ 'ericsson-virtual1' 'ericsson-virtual2' 'ericsson-virtual3' \ 'ericsson-virtual4' 'ericsson-virtual5' \ 'arm-pod1' 'arm-pod3' \ diff --git a/utils/test/testapi/htmlize/doc-build.sh b/utils/test/testapi/htmlize/doc-build.sh index e492c97b5..427b4378b 100644 --- a/utils/test/testapi/htmlize/doc-build.sh +++ b/utils/test/testapi/htmlize/doc-build.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -o errexit + # Create virtual environment source $WORKSPACE/testapi_venv/bin/activate diff --git a/utils/test/testapi/htmlize/htmlize.py b/utils/test/testapi/htmlize/htmlize.py index 68d02febd..c07f98ecf 100644 --- a/utils/test/testapi/htmlize/htmlize.py +++ b/utils/test/testapi/htmlize/htmlize.py @@ -28,7 +28,10 @@ def main(args): # Generating html page cmd = 'java -jar swagger-codegen-cli.jar generate \ -i specs.json -l html2 -o %s' % (args.output_directory) - os.system(cmd) + if os.system(cmd) == 0: + exit(0) + else: + exit(1) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Create \ diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py index 9fc5d6be1..5f6c3df57 100644 --- a/utils/test/testapi/opnfv_testapi/resources/handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py @@ -228,7 +228,7 @@ class GenericApiHandler(RequestHandler): class VersionHandler(GenericApiHandler): - @swagger.operation(nickname='List all versions') + @swagger.operation(nickname='listAllVersions') def get(self): """ @description: list all supported versions diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py index 631d4a91d..e1bd9d359 100644 --- a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py @@ -20,7 +20,7 @@ class GenericPodHandler(GenericApiHandler): class PodCLHandler(GenericPodHandler): - @swagger.operation(nickname='List all Pods') + @swagger.operation(nickname='listAllPods') def get(self): """ @description: list all pods @@ -29,7 +29,7 @@ class PodCLHandler(GenericPodHandler): """ self._list() - @swagger.operation(nickname='Create a Pod') + @swagger.operation(nickname='createPod') def post(self): """ @description: create a pod @@ -54,7 +54,7 @@ class PodCLHandler(GenericPodHandler): class PodGURHandler(GenericPodHandler): - @swagger.operation(nickname='Get a Pod by pod_name') + @swagger.operation(nickname='getPodByName') def get(self, pod_name): """ @description: get a single pod by pod_name diff --git a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py index 9cf698623..94c65b722 100644 --- a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py @@ -22,7 +22,7 @@ class GenericProjectHandler(GenericApiHandler): class ProjectCLHandler(GenericProjectHandler): - @swagger.operation(nickname="List all Projects") + @swagger.operation(nickname="listAllProjects") def get(self): """ @description: list all projects @@ -31,7 +31,7 @@ class ProjectCLHandler(GenericProjectHandler): """ self._list() - @swagger.operation(nickname="Create a Project") + @swagger.operation(nickname="createProject") def post(self): """ @description: create a project @@ -56,7 +56,7 @@ class ProjectCLHandler(GenericProjectHandler): class ProjectGURHandler(GenericProjectHandler): - @swagger.operation(nickname='Get a Project by project_name') + @swagger.operation(nickname='getProjectByName') def get(self, project_name): """ @description: get a single project by project_name @@ -66,7 +66,7 @@ class ProjectGURHandler(GenericProjectHandler): """ self._get_one({'name': project_name}) - @swagger.operation(nickname="Update a Project by project_name") + @swagger.operation(nickname="updateProjectByName") def put(self, project_name): """ @description: update a single project by project_name @@ -82,7 +82,7 @@ class ProjectGURHandler(GenericProjectHandler): db_keys = ['name'] self._update(query, db_keys) - @swagger.operation(nickname='Delete a Project by project_name') + @swagger.operation(nickname='deleteProjectByName') def delete(self, project_name): """ @description: delete a project by project_name diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py index fe13c09b7..2a1ed56ee 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py @@ -52,7 +52,7 @@ class GenericResultHandler(GenericApiHandler): class ResultsCLHandler(GenericResultHandler): - @swagger.operation(nickname="List all Test Results") + @swagger.operation(nickname="queryTestResults") def get(self): """ @description: Retrieve result(s) for a test project @@ -127,7 +127,7 @@ class ResultsCLHandler(GenericResultHandler): self._list(self.set_query(), sort=[('start_date', -1)], last=last) - @swagger.operation(nickname="Create a Test Result") + @swagger.operation(nickname="createTestResult") def post(self): """ @description: create a test result @@ -169,7 +169,7 @@ class ResultsCLHandler(GenericResultHandler): class ResultsGURHandler(GenericResultHandler): - @swagger.operation(nickname='Get a Test Result by result_id') + @swagger.operation(nickname='getTestResultById') def get(self, result_id): """ @description: get a single result by result_id @@ -181,7 +181,7 @@ class ResultsGURHandler(GenericResultHandler): query["_id"] = ObjectId(result_id) self._get_one(query) - @swagger.operation(nickname="Update a Test Result by result_id") + @swagger.operation(nickname="updateTestResultById") def put(self, result_id): """ @description: update a single result by _id diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py index 7bf3d5d53..a9b89eb89 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py @@ -14,18 +14,56 @@ class GenericScenarioHandler(GenericApiHandler): class ScenariosCLHandler(GenericScenarioHandler): - @swagger.operation(nickname="List scenarios by queries") + @swagger.operation(nickname="queryScenarios") def get(self): """ @description: Retrieve scenario(s). @notes: Retrieve scenario(s) - @return 200: all scenarios consist with query, + Available filters for this request are : + - name : scenario name + + GET /scenarios?name=scenario_1 + @param name: scenario name + @type name: L{string} + @in name: query + @required name: False + @param installer: installer type + @type installer: L{string} + @in installer: query + @required installer: False + @param version: version + @type version: L{string} + @in version: query + @required version: False + @param project: project name + @type project: L{string} + @in project: query + @required project: False + @return 200: all scenarios satisfy queries, empty list if no scenario is found @rtype: L{Scenarios} """ - self._list() - @swagger.operation(nickname="Create a new scenario") + def _set_query(): + query = dict() + elem_query = dict() + for k in self.request.query_arguments.keys(): + v = self.get_query_argument(k) + if k == 'installer': + elem_query["installer"] = v + elif k == 'version': + elem_query["versions.version"] = v + elif k == 'project': + elem_query["versions.projects.project"] = v + else: + query[k] = v + if elem_query: + query['installers'] = {'$elemMatch': elem_query} + return query + + self._list(_set_query()) + + @swagger.operation(nickname="createScenario") def post(self): """ @description: create a new scenario by name @@ -50,7 +88,7 @@ class ScenariosCLHandler(GenericScenarioHandler): class ScenarioGURHandler(GenericScenarioHandler): - @swagger.operation(nickname='Get the scenario by name') + @swagger.operation(nickname='getScenarioByName') def get(self, name): """ @description: get a single scenario by name @@ -58,14 +96,15 @@ class ScenarioGURHandler(GenericScenarioHandler): @return 200: scenario exist @raise 404: scenario not exist """ + self._get_one({'name': name}) pass - @swagger.operation(nickname="Update the scenario by name") + @swagger.operation(nickname="updateScenarioByName") def put(self, name): """ @description: update a single scenario by name @param body: fields to be updated - @type body: L{string} + @type body: L{ScenarioCreateRequest} @in body: body @rtype: L{Scenario} @return 200: update success diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py index b4bb3634b..f89a12428 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py @@ -11,7 +11,7 @@ class ScenarioTI(models.ModelBase): @swagger.model() class ScenarioScore(models.ModelBase): - def __init__(self, date=None, score=''): + def __init__(self, date=None, score='0'): self.date = date self.score = score @@ -27,14 +27,19 @@ class ScenarioProject(models.ModelBase): @ptype trust_indicators: C{list} of L{ScenarioTI} """ def __init__(self, - name='', + project='', customs=None, scores=None, trust_indicators=None): - self.name = name + self.project = project self.customs = customs self.scores = scores - self.trust_indicator = trust_indicators + self.trust_indicators = trust_indicators + + @staticmethod + def attr_parser(): + return {'scores': ScenarioScore, + 'trust_indicators': ScenarioTI} @swagger.model() @@ -43,10 +48,14 @@ class ScenarioVersion(models.ModelBase): @property projects: @ptype projects: C{list} of L{ScenarioProject} """ - def __init__(self, version, projects=None): + def __init__(self, version=None, projects=None): self.version = version self.projects = projects + @staticmethod + def attr_parser(): + return {'projects': ScenarioProject} + @swagger.model() class ScenarioInstaller(models.ModelBase): @@ -54,11 +63,14 @@ class ScenarioInstaller(models.ModelBase): @property versions: @ptype versions: C{list} of L{ScenarioVersion} """ - def __init__(self, installer=None, owner=None, versions=None): + def __init__(self, installer=None, versions=None): self.installer = installer - self.owner = owner self.versions = versions if versions else list() + @staticmethod + def attr_parser(): + return {'versions': ScenarioVersion} + @swagger.model() class ScenarioCreateRequest(models.ModelBase): @@ -70,6 +82,10 @@ class ScenarioCreateRequest(models.ModelBase): self.name = name self.installers = installers if installers else list() + @staticmethod + def attr_parser(): + return {'installers': ScenarioInstaller} + @swagger.model() class Scenario(models.ModelBase): @@ -83,6 +99,10 @@ class Scenario(models.ModelBase): self.creation_date = create_date self.installers = installers if installers else list() + @staticmethod + def attr_parser(): + return {'installers': ScenarioInstaller} + @swagger.model() class Scenarios(models.ModelBase): diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py b/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py index 3692b164f..100a4fd91 100644 --- a/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/testcase_handlers.py @@ -22,7 +22,7 @@ class GenericTestcaseHandler(GenericApiHandler): class TestcaseCLHandler(GenericTestcaseHandler): - @swagger.operation(nickname="List all TestCases by project_name") + @swagger.operation(nickname="listAllTestCases") def get(self, project_name): """ @description: list all testcases of a project by project_name @@ -34,7 +34,7 @@ class TestcaseCLHandler(GenericTestcaseHandler): query['project_name'] = project_name self._list(query) - @swagger.operation(nickname="Create a TestCase by project_name") + @swagger.operation(nickname="createTestCase") def post(self, project_name): """ @description: create a testcase of a project by project_name @@ -72,7 +72,7 @@ class TestcaseCLHandler(GenericTestcaseHandler): class TestcaseGURHandler(GenericTestcaseHandler): - @swagger.operation(nickname='Get a TestCase by project and case name') + @swagger.operation(nickname='getTestCaseByName') def get(self, project_name, case_name): """ @description: get a single testcase @@ -86,7 +86,7 @@ class TestcaseGURHandler(GenericTestcaseHandler): query["name"] = case_name self._get_one(query) - @swagger.operation(nickname="Update a TestCase by project and case name") + @swagger.operation(nickname="updateTestCaseByName") def put(self, project_name, case_name): """ @description: update a single testcase @@ -104,7 +104,7 @@ class TestcaseGURHandler(GenericTestcaseHandler): db_keys = ['name', 'project_name'] self._update(query, db_keys) - @swagger.operation(nickname='Delete a TestCase by project and case name') + @swagger.operation(nickname='deleteTestCaseByName') def delete(self, project_name, case_name): """ @description: delete a testcase by project_name and case_name diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py index d86d8eadf..3c4fd01a3 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py @@ -55,7 +55,8 @@ class MemCursor(object): class MemDb(object): - def __init__(self): + def __init__(self, name): + self.name = name self.contents = [] pass @@ -109,8 +110,59 @@ class MemDb(object): return True return False - @staticmethod - def _in(content, *args): + def _in(self, content, *args): + if self.name == 'scenarios': + return self._in_scenarios(content, *args) + else: + return self._in_others(content, *args) + + def _in_scenarios_installer(self, installer, content): + hit = False + for s_installer in content['installers']: + if installer == s_installer['installer']: + hit = True + + return hit + + def _in_scenarios_version(self, version, content): + hit = False + for s_installer in content['installers']: + for s_version in s_installer['versions']: + if version == s_version['version']: + hit = True + return hit + + def _in_scenarios_project(self, project, content): + hit = False + for s_installer in content['installers']: + for s_version in s_installer['versions']: + for s_project in s_version['projects']: + if project == s_project['project']: + hit = True + + return hit + + def _in_scenarios(self, content, *args): + for arg in args: + for k, v in arg.iteritems(): + if k == 'installers': + for inner in v.values(): + for i_k, i_v in inner.iteritems(): + if i_k == 'installer': + return self._in_scenarios_installer(i_v, + content) + elif i_k == 'versions.version': + return self._in_scenarios_version(i_v, + content) + elif i_k == 'versions.projects.project': + return self._in_scenarios_project(i_v, + content) + elif content.get(k, None) != v: + return False + + return True + + def _in_others(self, content, *args): for arg in args: for k, v in arg.iteritems(): if k == 'start_date': @@ -185,8 +237,8 @@ def __getattr__(name): return globals()[name] -pods = MemDb() -projects = MemDb() -testcases = MemDb() -results = MemDb() -scenarios = MemDb() +pods = MemDb('pods') +projects = MemDb('projects') +testcases = MemDb('testcases') +results = MemDb('results') +scenarios = MemDb('scenarios') diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-create.json b/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c1.json index eba8b6c0a..187802215 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-create.json +++ b/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c1.json @@ -35,4 +35,4 @@ ] } ] -}
\ No newline at end of file +} diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json b/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json new file mode 100644 index 000000000..b6a3b83ab --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/tests/unit/scenario-c2.json @@ -0,0 +1,73 @@ +{ + "name": "odl_2-nofeature-ha", + "installers": + [ + { + "installer": "fuel", + "versions": + [ + { + "owner": "Lucky", + "version": "colorado", + "projects": + [ + { + "project": "functest", + "customs": [ "healthcheck", "vping_ssh"], + "scores": [], + "trust_indicators": [ + { + "date": "2017-01-18 22:46:44", + "status": "silver" + } + + ] + }, + { + "project": "yardstick", + "customs": ["suite-a"], + "scores": [ + { + "date": "2017-01-08 22:46:44", + "score": "0" + } + ], + "trust_indicators": [ + { + "date": "2017-01-18 22:46:44", + "status": "gold" + } + ] + } + ] + }, + { + "owner": "Luke", + "version": "colorado", + "projects": + [ + { + "project": "functest", + "customs": [ "healthcheck", "vping_ssh"], + "scores": + [ + { + "date": "2017-01-09 22:46:44", + "score": "11/14" + } + + ], + "trust_indicators": [] + }, + { + "project": "yardstick", + "customs": [], + "scores": [], + "trust_indicators": [] + } + ] + } + ] + } + ] +} diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py b/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py index 9343ab2fb..fc780e44c 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/test_base.py @@ -47,11 +47,11 @@ class TestBase(AsyncHTTPTestCase): return self.create_help(self.basePath, req, *args) def create_help(self, uri, req, *args): - if req and not isinstance(req, str): - req = json.dumps(req.format()) + if req and not isinstance(req, str) and hasattr(req, 'format'): + req = req.format() res = self.fetch(self._update_uri(uri, *args), method='POST', - body=req if req else json.dumps(None), + body=json.dumps(req), headers=self.headers) return self._get_return(res, self.create_res) @@ -97,7 +97,7 @@ class TestBase(AsyncHTTPTestCase): return uri.count('%s') def _get_query_uri(self, query): - return self.basePath + '?' + query + return self.basePath + '?' + query if query else self.basePath def _get_uri(self, *args): return self._update_uri(self.basePath, *args) 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 8e827813c..ff5979524 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/test_scenario.py @@ -4,15 +4,20 @@ import os from opnfv_testapi.common.constants import HTTP_BAD_REQUEST from opnfv_testapi.common.constants import HTTP_FORBIDDEN from opnfv_testapi.common.constants import HTTP_OK +from opnfv_testapi.resources.scenario_models import Scenario from opnfv_testapi.resources.scenario_models import ScenarioCreateRequest +from opnfv_testapi.resources.scenario_models import Scenarios from test_testcase import TestBase class TestScenarioBase(TestBase): def setUp(self): super(TestScenarioBase, self).setUp() + self.get_res = Scenario + self.list_res = Scenarios self.basePath = '/api/v1/scenarios' - self.load_request('scenario-create.json') + self.req_d = self._load_request('scenario-c1.json') + self.req_2 = self._load_request('scenario-c2.json') def tearDown(self): pass @@ -20,10 +25,26 @@ class TestScenarioBase(TestBase): def assert_body(self, project, req=None): pass - def load_request(self, f_req): - with open(os.path.join(os.path.dirname(__file__), f_req), 'r') as f: - self.req_d = json.dumps(json.load(f)) + @staticmethod + def _load_request(f_req): + abs_file = os.path.join(os.path.dirname(__file__), f_req) + with open(abs_file, 'r') as f: + loader = json.load(f) f.close() + return loader + + def create_return_name(self, req): + _, res = self.create(req) + return res.href.split('/')[-1] + + def assert_res(self, code, scenario, req=None): + self.assertEqual(code, HTTP_OK) + if req is None: + req = self.req_d + scenario_dict = scenario.format_http() + self.assertIsNotNone(scenario_dict['_id']) + self.assertIsNotNone(scenario_dict['creation_date']) + self.assertDictContainsSubset(req, scenario_dict) class TestScenarioCreate(TestScenarioBase): @@ -53,3 +74,60 @@ class TestScenarioCreate(TestScenarioBase): (code, body) = self.create_d() self.assertEqual(code, HTTP_FORBIDDEN) self.assertIn('already exists', body) + + +class TestScenarioGet(TestScenarioBase): + def setUp(self): + super(TestScenarioGet, self).setUp() + self.scenario_1 = self.create_return_name(self.req_d) + self.scenario_2 = self.create_return_name(self.req_2) + + def test_getByName(self): + code, body = self.get(self.scenario_1) + self.assert_res(code, body, req=self.req_d) + + def test_getAll(self): + self._query_and_assert(query=None, reqs=[self.req_d, self.req_2]) + + def test_queryName(self): + query = self._set_query('name=nosdn-nofeature-ha') + self._query_and_assert(query, reqs=[self.req_d]) + + def test_queryInstaller(self): + query = self._set_query('installer=apex') + self._query_and_assert(query, reqs=[self.req_d]) + + def test_queryVersion(self): + query = self._set_query('version=master') + self._query_and_assert(query, reqs=[self.req_d]) + + def test_queryProject(self): + query = self._set_query('project=functest') + self._query_and_assert(query, reqs=[self.req_d, self.req_2]) + + def test_queryCombination(self): + query = self._set_query('name=nosdn-nofeature-ha', + 'installer=apex', + 'version=master', + 'project=functest') + + self._query_and_assert(query, reqs=[self.req_d]) + + @staticmethod + def _set_query(*args): + uri = '' + for arg in args: + uri += arg + '&' + return uri[0: -1] + + def _query_and_assert(self, query, found=True, reqs=None): + code, body = self.query(query) + if not found: + self.assertEqual(code, HTTP_OK) + self.assertEqual(0, len(body.scenarios)) + else: + self.assertEqual(len(reqs), len(body.scenarios)) + for req in reqs: + for scenario in body.scenarios: + if req['name'] == scenario.name: + self.assert_res(code, scenario, req) diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh index 9b25f8ffc..d1f05f201 100755 --- a/utils/test/testapi/run_test.sh +++ b/utils/test/testapi/run_test.sh @@ -1,10 +1,40 @@ -#! /bin/bash +#!/bin/bash -# Before run this script, make sure that testtools and discover -# had been installed in your env -# or else using pip to install them as follows: -# pip install testtools, discover +set -o errexit + +# Get script directory +SCRIPTDIR=`dirname $0` + +# Either Workspace is set (CI) +if [ -z $WORKSPACE ] +then + WORKSPACE="." +fi + +echo "Running unit tests..." + +# Creating virtual environment +virtualenv $WORKSPACE/testapi_venv +source $WORKSPACE/testapi_venv/bin/activate + +# Install requirements +pip install -r $SCRIPTDIR/requirements.txt find . -type f -name "*.pyc" -delete -testrargs="discover ./opnfv_testapi/tests/unit" -python -m testtools.run $testrargs + +nosetests --with-xunit \ + --with-coverage \ + --cover-erase \ + --cover-package=$SCRIPTDIR/opnfv_testapi/cmd \ + --cover-package=$SCRIPTDIR/opnfv_testapi/commonn \ + --cover-package=$SCRIPTDIR/opnfv_testapi/resources \ + --cover-package=$SCRIPTDIR/opnfv_testapi/router \ + --cover-xml \ + --cover-html \ + $SCRIPTDIR/opnfv_testapi/tests + +exit_code=$? + +deactivate + +exit $exit_code diff --git a/utils/test/testapi/test-requirements.txt b/utils/test/testapi/test-requirements.txt deleted file mode 100644 index ddbdefcfd..000000000 --- a/utils/test/testapi/test-requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - -testtools>=1.4.0 -discover -futures
\ No newline at end of file |