diff options
49 files changed, 1247 insertions, 521 deletions
diff --git a/jjb/apex/apex.yml b/jjb/apex/apex.yml index a395cf2e5..fd4dc9ff5 100644 --- a/jjb/apex/apex.yml +++ b/jjb/apex/apex.yml @@ -13,13 +13,14 @@ - 'apex-csit-promote-daily-{stream}' - 'apex-fdio-promote-daily-{stream}' - 'apex-verify-iso-{stream}' - - 'apex-run-deploy-test-baremetal-{stream}' + - 'apex-{scenario}-baremetal-{scenario_stream}' + - 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' - 'apex-upload-snapshot' - 'apex-create-snapshot' # stream: branch with - in place of / (eg. stable-arno) # branch: branch (eg. stable/arno) stream: - - master: + - master: &master branch: 'master' gs-pathname: '' build-slave: 'apex-build-master' @@ -27,8 +28,9 @@ baremetal-slave: 'apex-baremetal-master' verify-scenario: 'os-odl-nofeature-ha' concurrent-builds: 3 + scenario_stream: 'master' - - danube: + - danube: &danube branch: 'stable/danube' gs-pathname: '/danube' build-slave: 'apex-build-danube' @@ -36,7 +38,72 @@ baremetal-slave: 'apex-baremetal-danube' verify-scenario: 'os-odl_l3-nofeature-ha' concurrent-builds: 1 - disabled: false + scenario_stream: 'danube' + disabled: true + + scenario: + - 'os-nosdn-nofeature-noha': + <<: *danube + - 'os-nosdn-nofeature-ha': + <<: *danube + - 'os-nosdn-nofeature-ha-ipv6': + <<: *danube + - 'os-nosdn-ovs-noha': + <<: *danube + - 'os-nosdn-ovs-ha': + <<: *danube + - 'os-nosdn-fdio-noha': + <<: *danube + - 'os-nosdn-fdio-ha': + <<: *danube + - 'os-nosdn-kvm-ha': + <<: *danube + - 'os-nosdn-kvm-noha': + <<: *danube + - 'os-odl_l2-fdio-noha': + <<: *danube + - 'os-odl_l2-fdio-ha': + <<: *danube + - 'os-odl_netvirt-fdio-noha': + <<: *danube + - 'os-odl_l2-sfc-noha': + <<: *danube + - 'os-odl_l3-nofeature-noha': + <<: *danube + - 'os-odl_l3-nofeature-ha': + <<: *danube + - 'os-odl_l3-ovs-noha': + <<: *danube + - 'os-odl_l3-ovs-ha': + <<: *danube + - 'os-odl-bgpvpn-ha': + <<: *danube + - 'os-odl-gluon-noha': + <<: *danube + - 'os-odl_l3-fdio-noha': + <<: *danube + - 'os-odl_l3-fdio-ha': + <<: *danube + - 'os-odl_l3-fdio_dvr-noha': + <<: *danube + - 'os-odl_l3-fdio_dvr-ha': + <<: *danube + - 'os-odl_l3-csit-noha': + <<: *danube + - 'os-onos-nofeature-ha': + <<: *danube + - 'os-ovn-nofeature-noha': + <<: *danube + - 'os-nosdn-nofeature-noha': + <<: *master + - 'os-nosdn-nofeature-ha': + <<: *master + - 'os-odl-nofeature-ha': + <<: *master + - 'os-odl-nofeature-noha': + <<: *master + - 'os-odl-bgpvpn-ha': + <<: *master platform: - 'baremetal' @@ -478,11 +545,6 @@ - job-template: name: 'apex-deploy-{platform}-{stream}' - # Job template for virtual deployment - # - # Required Variables: - # stream: branch with - in place of / (eg. stable) - # branch: branch (eg. stable) node: 'apex-{platform}-{stream}' concurrent: true @@ -498,6 +560,7 @@ fail: true parameters: + - '{project}-{platform}-{stream}-defaults' - project-parameter: project: '{project}' branch: '{branch}' @@ -521,6 +584,7 @@ - 'apex-deploy.*' - 'functest.*' - 'yardstick.*' + - 'dovetail.*' - throttle: max-per-node: 1 max-total: 10 @@ -536,13 +600,8 @@ # Baremetal Deploy and Test - job-template: - name: 'apex-run-deploy-test-baremetal-{stream}' + name: 'apex-{scenario}-baremetal-{scenario_stream}' - # Job template for daily build - # - # Required Variables: - # stream: branch with - in place of / (eg. stable) - # branch: branch (eg. stable) project-type: 'multijob' disabled: false @@ -552,7 +611,7 @@ parameters: - '{project}-defaults' - - '{project}-baremetal-{stream}-defaults' + - '{project}-baremetal-{scenario_stream}-defaults' - project-parameter: project: '{project}' branch: '{branch}' @@ -560,7 +619,7 @@ gs-pathname: '{gs-pathname}' - string: name: DEPLOY_SCENARIO - default: '{verify-scenario}' + default: '{scenario}' description: "Scenario to deploy with." properties: - logrotate-default @@ -572,6 +631,11 @@ - 'apex-runner.*' - 'apex-.*-promote.*' - 'apex-run.*' + - 'apex-.+-baremetal-.+' + - throttle: + max-per-node: 1 + max-total: 10 + option: 'project' builders: - description-setter: description: "Deployed on $NODE_NAME - Scenario: $DEPLOY_SCENARIO" @@ -579,7 +643,7 @@ name: 'Baremetal Deploy' condition: ALWAYS projects: - - name: 'apex-deploy-baremetal-{stream}' + - name: 'apex-deploy-baremetal-{scenario_stream}' node-parameters: true current-parameters: true predefined-parameters: | @@ -591,10 +655,62 @@ abort-all-job: true git-revision: false - multijob: + name: 'OPNFV Test Suite' + condition: SUCCESSFUL + projects: + - name: 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' + node-parameters: true + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + kill-phase-on: NEVER + abort-all-job: true + git-revision: false + + +# Baremetal test job +- job-template: + name: 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' + + project-type: 'multijob' + + disabled: false + + parameters: + - '{project}-defaults' + - '{project}-baremetal-{scenario_stream}-defaults' + - project-parameter: + project: '{project}' + branch: '{branch}' + - apex-parameter: + gs-pathname: '{gs-pathname}' + - string: + name: DEPLOY_SCENARIO + default: '{scenario}' + description: "Scenario to deploy with." + properties: + - logrotate-default + - build-blocker: + use-build-blocker: true + block-level: 'NODE' + blocking-jobs: + - 'apex-verify.*' + - 'apex-runner.*' + - 'apex-.*-promote.*' + - 'apex-run.*' + - 'apex-testsuite-.+-baremetal-.+' + - throttle: + max-per-node: 1 + max-total: 10 + option: 'project' + builders: + - description-setter: + description: "Testing on $NODE_NAME - Scenario: $DEPLOY_SCENARIO" + - multijob: name: Functest condition: ALWAYS projects: - - name: 'functest-apex-baremetal-daily-{stream}' + - name: 'functest-apex-baremetal-daily-{scenario_stream}' node-parameters: true current-parameters: false predefined-parameters: @@ -606,7 +722,7 @@ name: Yardstick condition: ALWAYS projects: - - name: 'yardstick-apex-baremetal-daily-{stream}' + - name: 'yardstick-apex-baremetal-daily-{scenario_stream}' node-parameters: true current-parameters: false predefined-parameters: @@ -614,6 +730,26 @@ kill-phase-on: NEVER abort-all-job: false git-revision: false + - multijob: + name: Dovetail + condition: ALWAYS + projects: + - name: 'dovetail-apex-baremetal-proposed_tests-{scenario_stream}' + node-parameters: true + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + kill-phase-on: NEVER + enable-condition: "def m = '$DEPLOY_SCENARIO' ==~ /os-(nosdn-nofeature|nosdn-kvm|odl_l3-fdio)-ha/" + abort-all-job: false + git-revision: false + - conditional-step: + condition-kind: current-status + condition-worst: SUCCESS + condtion-best: SUCCESS + on-evaluation-failure: mark-unstable + steps: + - shell: 'echo "Tests Passed"' # danube Daily @@ -686,261 +822,235 @@ condition: SUCCESSFUL projects: - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-nofeature-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-nofeature-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-nofeature-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-nofeature-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-nofeature-ha-ipv6-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-nofeature-ha-ipv6 OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-ovs-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-ovs-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-ovs-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-ovs-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-fdio-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-fdio-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-fdio-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-fdio-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-kvm-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-kvm-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-nosdn-kvm-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-kvm-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l2-fdio-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l2-fdio-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l2-fdio-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l2-fdio-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_netvirt-fdio-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_netvirt-fdio-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l2-sfc-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l2-sfc-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-nofeature-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-nofeature-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-nofeature-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-nofeature-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-ovs-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-ovs-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-ovs-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-ovs-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl-bgpvpn-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl-bgpvpn-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl-gluon-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl-gluon-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-fdio-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-fdio-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-fdio-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-fdio-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-fdio_dvr-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-fdio_dvr-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-fdio_dvr-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-fdio_dvr-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-odl_l3-csit-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl_l3-csit-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-onos-nofeature-ha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-onos-nofeature-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-danube' + - name: 'apex-os-ovn-nofeature-noha-baremetal-danube' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-ovn-nofeature-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true @@ -1017,41 +1127,46 @@ condition: SUCCESSFUL projects: - - name: 'apex-run-deploy-test-baremetal-master' + - name: 'apex-os-nosdn-nofeature-noha-baremetal-master' + node-parameters: false + current-parameters: false + predefined-parameters: | + OPNFV_CLEAN=yes + kill-phase-on: NEVER + abort-all-job: true + git-revision: false + + - name: 'apex-os-nosdn-nofeature-ha-baremetal-master' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-nofeature-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-master' + - name: 'apex-os-odl-nofeature-ha-baremetal-master' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-nosdn-nofeature-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-master' + - name: 'apex-os-odl-nofeature-noha-baremetal-master' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl-nofeature-ha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true git-revision: false - - name: 'apex-run-deploy-test-baremetal-master' + - name: 'apex-os-odl-bgpvpn-ha-baremetal-master' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO=os-odl-nofeature-noha OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true @@ -1385,8 +1500,8 @@ - trigger: name: 'apex-master' triggers: - - timed: '0 3 1 1 7' + - timed: '0 12 * * *' - trigger: name: 'apex-danube' triggers: - - timed: '0 12 * * *' + - timed: '0 3 1 1 7' diff --git a/jjb/apex/apex.yml.j2 b/jjb/apex/apex.yml.j2 index 752cf281d..d7b67c344 100644 --- a/jjb/apex/apex.yml.j2 +++ b/jjb/apex/apex.yml.j2 @@ -13,13 +13,14 @@ - 'apex-csit-promote-daily-{stream}' - 'apex-fdio-promote-daily-{stream}' - 'apex-verify-iso-{stream}' - - 'apex-run-deploy-test-baremetal-{stream}' + - 'apex-{scenario}-baremetal-{scenario_stream}' + - 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' - 'apex-upload-snapshot' - 'apex-create-snapshot' # stream: branch with - in place of / (eg. stable-arno) # branch: branch (eg. stable/arno) stream: - - master: + - master: &master branch: 'master' gs-pathname: '' build-slave: 'apex-build-master' @@ -27,8 +28,9 @@ baremetal-slave: 'apex-baremetal-master' verify-scenario: 'os-odl-nofeature-ha' concurrent-builds: 3 + scenario_stream: 'master' - - danube: + - danube: &danube branch: 'stable/danube' gs-pathname: '/danube' build-slave: 'apex-build-danube' @@ -36,7 +38,16 @@ baremetal-slave: 'apex-baremetal-danube' verify-scenario: 'os-odl_l3-nofeature-ha' concurrent-builds: 1 - disabled: false + scenario_stream: 'danube' + disabled: true + + scenario: + {%- for stream in scenarios %} + {%- for scenario in scenarios[stream] %} + - '{{scenario}}': + <<: *{{stream}} + {%- endfor %} + {%- endfor %} platform: - 'baremetal' @@ -478,11 +489,6 @@ - job-template: name: 'apex-deploy-{platform}-{stream}' - # Job template for virtual deployment - # - # Required Variables: - # stream: branch with - in place of / (eg. stable) - # branch: branch (eg. stable) node: 'apex-{platform}-{stream}' concurrent: true @@ -498,6 +504,7 @@ fail: true parameters: + - '{project}-{platform}-{stream}-defaults' - project-parameter: project: '{project}' branch: '{branch}' @@ -521,6 +528,7 @@ - 'apex-deploy.*' - 'functest.*' - 'yardstick.*' + - 'dovetail.*' - throttle: max-per-node: 1 max-total: 10 @@ -536,13 +544,8 @@ # Baremetal Deploy and Test - job-template: - name: 'apex-run-deploy-test-baremetal-{stream}' + name: 'apex-{scenario}-baremetal-{scenario_stream}' - # Job template for daily build - # - # Required Variables: - # stream: branch with - in place of / (eg. stable) - # branch: branch (eg. stable) project-type: 'multijob' disabled: false @@ -552,7 +555,7 @@ parameters: - '{project}-defaults' - - '{project}-baremetal-{stream}-defaults' + - '{project}-baremetal-{scenario_stream}-defaults' - project-parameter: project: '{project}' branch: '{branch}' @@ -560,7 +563,7 @@ gs-pathname: '{gs-pathname}' - string: name: DEPLOY_SCENARIO - default: '{verify-scenario}' + default: '{scenario}' description: "Scenario to deploy with." properties: - logrotate-default @@ -572,6 +575,11 @@ - 'apex-runner.*' - 'apex-.*-promote.*' - 'apex-run.*' + - 'apex-.+-baremetal-.+' + - throttle: + max-per-node: 1 + max-total: 10 + option: 'project' builders: - description-setter: description: "Deployed on $NODE_NAME - Scenario: $DEPLOY_SCENARIO" @@ -579,7 +587,7 @@ name: 'Baremetal Deploy' condition: ALWAYS projects: - - name: 'apex-deploy-baremetal-{stream}' + - name: 'apex-deploy-baremetal-{scenario_stream}' node-parameters: true current-parameters: true predefined-parameters: | @@ -591,10 +599,62 @@ abort-all-job: true git-revision: false - multijob: + name: 'OPNFV Test Suite' + condition: SUCCESSFUL + projects: + - name: 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' + node-parameters: true + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + kill-phase-on: NEVER + abort-all-job: true + git-revision: false + + +# Baremetal test job +- job-template: + name: 'apex-testsuite-{scenario}-baremetal-{scenario_stream}' + + project-type: 'multijob' + + disabled: false + + parameters: + - '{project}-defaults' + - '{project}-baremetal-{scenario_stream}-defaults' + - project-parameter: + project: '{project}' + branch: '{branch}' + - apex-parameter: + gs-pathname: '{gs-pathname}' + - string: + name: DEPLOY_SCENARIO + default: '{scenario}' + description: "Scenario to deploy with." + properties: + - logrotate-default + - build-blocker: + use-build-blocker: true + block-level: 'NODE' + blocking-jobs: + - 'apex-verify.*' + - 'apex-runner.*' + - 'apex-.*-promote.*' + - 'apex-run.*' + - 'apex-testsuite-.+-baremetal-.+' + - throttle: + max-per-node: 1 + max-total: 10 + option: 'project' + builders: + - description-setter: + description: "Testing on $NODE_NAME - Scenario: $DEPLOY_SCENARIO" + - multijob: name: Functest condition: ALWAYS projects: - - name: 'functest-apex-baremetal-daily-{stream}' + - name: 'functest-apex-baremetal-daily-{scenario_stream}' node-parameters: true current-parameters: false predefined-parameters: @@ -606,14 +666,34 @@ name: Yardstick condition: ALWAYS projects: - - name: 'yardstick-apex-baremetal-daily-{stream}' + - name: 'yardstick-apex-baremetal-daily-{scenario_stream}' + node-parameters: true + current-parameters: false + predefined-parameters: + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + kill-phase-on: NEVER + abort-all-job: false + git-revision: false + - multijob: + name: Dovetail + condition: ALWAYS + projects: + - name: 'dovetail-apex-baremetal-proposed_tests-{scenario_stream}' node-parameters: true current-parameters: false predefined-parameters: DEPLOY_SCENARIO=$DEPLOY_SCENARIO kill-phase-on: NEVER + enable-condition: "def m = '$DEPLOY_SCENARIO' ==~ /os-(nosdn-nofeature|nosdn-kvm|odl_l3-fdio)-ha/" abort-all-job: false git-revision: false + - conditional-step: + condition-kind: current-status + condition-worst: SUCCESS + condtion-best: SUCCESS + on-evaluation-failure: mark-unstable + steps: + - shell: 'echo "Tests Passed"' {% for stream in scenarios %} # {{ stream }} Daily @@ -686,11 +766,10 @@ condition: SUCCESSFUL projects: {% for scenario in scenarios[stream] %} - - name: 'apex-run-deploy-test-baremetal-{{ stream }}' + - name: 'apex-{{ scenario }}-baremetal-{{ stream }}' node-parameters: false current-parameters: false predefined-parameters: | - DEPLOY_SCENARIO={{scenario}} OPNFV_CLEAN=yes kill-phase-on: NEVER abort-all-job: true @@ -1024,9 +1103,9 @@ - trigger: name: 'apex-master' triggers: - - timed: '0 3 1 1 7' + - timed: '0 12 * * *' - trigger: name: 'apex-danube' triggers: - - timed: '0 12 * * *' + - timed: '0 3 1 1 7' diff --git a/jjb/apex/scenarios.yaml.hidden b/jjb/apex/scenarios.yaml.hidden index dc9107a11..748cd21b8 100644 --- a/jjb/apex/scenarios.yaml.hidden +++ b/jjb/apex/scenarios.yaml.hidden @@ -3,6 +3,7 @@ master: - 'os-nosdn-nofeature-ha' - 'os-odl-nofeature-ha' - 'os-odl-nofeature-noha' + - 'os-odl-bgpvpn-ha' danube: - 'os-nosdn-nofeature-noha' - 'os-nosdn-nofeature-ha' diff --git a/jjb/armband/armband-deploy.sh b/jjb/armband/armband-deploy.sh index 9964ed5cc..358b55ba2 100755 --- a/jjb/armband/armband-deploy.sh +++ b/jjb/armband/armband-deploy.sh @@ -70,10 +70,6 @@ if [[ $LAB_CONFIG_URL =~ ^(git|ssh):// ]]; then fi fi -if [[ "$NODE_NAME" =~ "virtual" ]]; then - POD_NAME="virtual_kvm" -fi - # releng wants us to use nothing else but opnfv.iso for now. We comply. ISO_FILE=$WORKSPACE/opnfv.iso diff --git a/jjb/compass4nfv/compass-ci-jobs.yml b/jjb/compass4nfv/compass-ci-jobs.yml index 3335391ca..310347de2 100644 --- a/jjb/compass4nfv/compass-ci-jobs.yml +++ b/jjb/compass4nfv/compass-ci-jobs.yml @@ -10,12 +10,14 @@ stream: master branch: '{stream}' gs-pathname: '' + ppa-pathname: '/{stream}' disabled: false openstack-version: ocata danube: &danube stream: danube branch: 'stable/{stream}' gs-pathname: '/{stream}' + ppa-pathname: '/{stream}' disabled: false openstack-version: newton #-------------------------------- @@ -76,6 +78,15 @@ - 'os-nosdn-openo-ha': disabled: false auto-trigger-name: 'compass-{scenario}-{pod}-{stream}-trigger' + - 'os-odl-sfc-ha': + disabled: false + auto-trigger-name: 'compass-{scenario}-{pod}-{stream}-trigger' + - 'os-nosdn-dpdk-ha': + disabled: false + auto-trigger-name: 'compass-{scenario}-{pod}-{stream}-trigger' + - 'k8-nosdn-nofeature-ha': + disabled: false + auto-trigger-name: 'compass-{scenario}-{pod}-{stream}-trigger' jobs: @@ -118,6 +129,7 @@ - compass-ci-parameter: installer: '{installer}' gs-pathname: '{gs-pathname}' + ppa-pathname: '{ppa-pathname}' - string: name: DEPLOY_SCENARIO default: '{scenario}' @@ -281,6 +293,7 @@ - compass-ci-parameter: installer: '{installer}' gs-pathname: '{gs-pathname}' + ppa-pathname: '{ppa-pathname}' - '{slave-label}-defaults' - '{installer}-defaults' @@ -290,10 +303,25 @@ builders: - description-setter: description: "POD: $NODE_NAME" - - shell: - !include-raw-escape: ./compass-download-artifact.sh - - shell: - !include-raw-escape: ./compass-deploy.sh + - conditional-step: + condition-kind: regex-match + regex: master + label: '{stream}' + steps: + - shell: + !include-raw-escape: ./compass-build.sh + - shell: + !include-raw-escape: ./compass-deploy.sh + - conditional-step: + condition-kind: regex-match + regex: danube + label: '{stream}' + steps: + - shell: + !include-raw-escape: ./compass-download-artifact.sh + - shell: + !include-raw-escape: ./compass-deploy.sh + ######################## # parameter macros @@ -309,6 +337,16 @@ name: GS_URL default: '$GS_BASE{gs-pathname}' description: "URL to Google Storage." + - string: + name: CACHE_DIRECTORY + default: "$HOME/opnfv/cache/$PROJECT{gs-pathname}" + description: "Directory where the cache to be used during the build is located." + - string: + name: PPA_REPO + default: "http://artifacts.opnfv.org/compass4nfv/package{ppa-pathname}" + - string: + name: PPA_CACHE + default: "$WORKSPACE/work/repo/" ######################## # trigger macros @@ -349,6 +387,18 @@ name: 'compass-os-nosdn-kvm-ha-baremetal-centos-master-trigger' triggers: - timed: '' +- trigger: + name: 'compass-os-nosdn-dpdk-ha-baremetal-centos-master-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-os-odl-sfc-ha-baremetal-centos-master-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-k8-nosdn-nofeature-ha-baremetal-centos-master-trigger' + triggers: + - timed: '' - trigger: name: 'compass-os-nosdn-nofeature-ha-baremetal-master-trigger' @@ -385,7 +435,20 @@ - trigger: name: 'compass-os-nosdn-kvm-ha-baremetal-master-trigger' triggers: - - timed: '' + - timed: '0 14 * * *' +- trigger: + name: 'compass-os-nosdn-dpdk-ha-baremetal-master-trigger' + triggers: + - timed: '0 16 * * *' +- trigger: + name: 'compass-k8-nosdn-nofeature-ha-baremetal-master-trigger' + triggers: + - timed: '0 20 * * *' +- trigger: + name: 'compass-os-odl-sfc-ha-baremetal-master-trigger' + triggers: + - timed: '0 4 * * *' + - trigger: name: 'compass-os-nosdn-nofeature-ha-baremetal-danube-trigger' @@ -423,6 +486,19 @@ name: 'compass-os-nosdn-kvm-ha-baremetal-danube-trigger' triggers: - timed: '' +- trigger: + name: 'compass-os-nosdn-dpdk-ha-baremetal-danube-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-k8-nosdn-nofeature-ha-baremetal-danube-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-os-odl-sfc-ha-baremetal-danube-trigger' + triggers: + - timed: '' + - trigger: name: 'compass-os-nosdn-nofeature-ha-virtual-master-trigger' @@ -459,7 +535,19 @@ - trigger: name: 'compass-os-nosdn-kvm-ha-virtual-master-trigger' triggers: - - timed: '' + - timed: '0 23 * * *' +- trigger: + name: 'compass-os-nosdn-dpdk-ha-virtual-master-trigger' + triggers: + - timed: '0 17 * * *' +- trigger: + name: 'compass-k8-nosdn-nofeature-ha-virtual-master-trigger' + triggers: + - timed: '0 18 * * *' +- trigger: + name: 'compass-os-odl-sfc-ha-virtual-master-trigger' + triggers: + - timed: '0 16 * * *' - trigger: name: 'compass-os-nosdn-nofeature-ha-virtual-danube-trigger' @@ -497,3 +585,15 @@ name: 'compass-os-nosdn-kvm-ha-virtual-danube-trigger' triggers: - timed: '' +- trigger: + name: 'compass-os-nosdn-dpdk-ha-virtual-danube-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-os-odl-sfc-ha-virtual-danube-trigger' + triggers: + - timed: '' +- trigger: + name: 'compass-k8-nosdn-nofeature-ha-virtual-danube-trigger' + triggers: + - timed: '' diff --git a/jjb/compass4nfv/compass-deploy.sh b/jjb/compass4nfv/compass-deploy.sh index 2668ccdf8..7a5af5f5b 100644 --- a/jjb/compass4nfv/compass-deploy.sh +++ b/jjb/compass4nfv/compass-deploy.sh @@ -6,24 +6,23 @@ echo "Starting the deployment on baremetal environment using $INSTALLER_TYPE. Th echo "--------------------------------------------------------" echo -# source the properties file so we get OPNFV vars -source $BUILD_DIRECTORY/latest.properties - -# echo the info about artifact that is used during the deployment -echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment" - -if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then - # for none-merge deployments - # checkout the commit that was used for building the downloaded artifact - # to make sure the ISO and deployment mechanism uses same versions - echo "Checking out $OPNFV_GIT_SHA1" - git checkout $OPNFV_GIT_SHA1 --quiet -fi - echo 1 > /proc/sys/vm/drop_caches export CONFDIR=$WORKSPACE/deploy/conf if [[ "$BRANCH" = 'stable/danube' ]]; then + # source the properties file so we get OPNFV vars + source $BUILD_DIRECTORY/latest.properties + # echo the info about artifact that is used during the deployment + echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment" + + if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then + # for none-merge deployments + # checkout the commit that was used for building the downloaded artifact + # to make sure the ISO and deployment mechanism uses same versions + echo "Checking out $OPNFV_GIT_SHA1" + git checkout $OPNFV_GIT_SHA1 --quiet + fi + export ISO_URL=file://$BUILD_DIRECTORY/compass.iso else export ISO_URL=file://$BUILD_DIRECTORY/compass.tar.gz @@ -40,6 +39,8 @@ elif [[ "${DEPLOY_SCENARIO}" =~ "-onos" ]]; then export NETWORK_CONF_FILE=network_onos.yml elif [[ "${DEPLOY_SCENARIO}" =~ "-openo" ]]; then export NETWORK_CONF_FILE=network_openo.yml +elif [[ "${DEPLOY_SCENARIO}" =~ "-dpdk" ]]; then + export NETWORK_CONF_FILE=network_dpdk.yml else export NETWORK_CONF_FILE=network.yml fi diff --git a/jjb/doctor/doctor.yml b/jjb/doctor/doctor.yml index 5bb8f7499..c6b2cb6d0 100644 --- a/jjb/doctor/doctor.yml +++ b/jjb/doctor/doctor.yml @@ -196,7 +196,7 @@ wget https://git.opnfv.org/functest/plain/functest/ci/download_images.sh -O functest/ci/download_images.sh - 'functest-suite-builder' - shell: | - functest_log="$HOME/opnfv/functest/results/{stream}/{project}.log" + functest_log="$HOME/opnfv/functest/results/{stream}/$FUNCTEST_SUITE_NAME.log" # NOTE: checking the test result, as the previous job could return # 0 regardless the result of doctor test scenario. grep -e ' OK$' $functest_log || exit 1 @@ -205,7 +205,7 @@ - archive: artifacts: 'tests/*.log' - archive: - artifacts: 'functest_results/{project}.log' + artifacts: 'functest_results/$FUNCTEST_SUITE_NAME.log' ##################################### diff --git a/jjb/dovetail/dovetail-ci-jobs.yml b/jjb/dovetail/dovetail-ci-jobs.yml index 43978f6dc..bcda2b7ca 100644 --- a/jjb/dovetail/dovetail-ci-jobs.yml +++ b/jjb/dovetail/dovetail-ci-jobs.yml @@ -25,7 +25,7 @@ branch: 'stable/{stream}' dovetail-branch: master gs-pathname: '/{stream}' - docker-tag: 'cvp.0.2.0' + docker-tag: 'cvp.0.3.0' #----------------------------------- # POD, PLATFORM, AND BRANCH MAPPING @@ -88,13 +88,23 @@ # that have not been switched using labels for slaves #-------------------------------- #apex PODs - - lf-pod1: - slave-label: '{pod}' + - virtual: + slave-label: apex-virtual-master SUT: apex auto-trigger-name: 'daily-trigger-disabled' <<: *master - - lf-pod1: - slave-label: '{pod}' + - baremetal: + slave-label: apex-baremetal-master + SUT: apex + auto-trigger-name: 'daily-trigger-disabled' + <<: *master + - virtual: + slave-label: apex-virtual-danube + SUT: apex + auto-trigger-name: 'daily-trigger-disabled' + <<: *danube + - baremetal: + slave-label: apex-baremetal-danube SUT: apex auto-trigger-name: 'daily-trigger-disabled' <<: *danube @@ -169,7 +179,6 @@ <<: *danube #-------------------------------- testsuite: - - 'debug' - 'compliance_set' - 'proposed_tests' diff --git a/jjb/functest/functest-alpine.sh b/jjb/functest/functest-alpine.sh new file mode 100644 index 000000000..9084ccaa7 --- /dev/null +++ b/jjb/functest/functest-alpine.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +set -e +set +u +set +o pipefail + +[[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null" +FUNCTEST_DIR=/home/opnfv/functest + +# Prepare OpenStack credentials volume +if [[ ${INSTALLER_TYPE} == 'joid' ]]; then + rc_file=$LAB_CONFIG/admin-openrc +elif [[ ${INSTALLER_TYPE} == 'compass' && ${BRANCH} == 'master' ]]; then + cacert_file_vol="-v ${HOME}/os_cacert:${FUNCTEST_DIR}/conf/os_cacert" + echo "export OS_CACERT=${FUNCTEST_DIR}/conf/os_cacert" >> ${HOME}/opnfv-openrc.sh + rc_file=${HOME}/opnfv-openrc.sh +else + rc_file=${HOME}/opnfv-openrc.sh +fi +rc_file_vol="-v ${rc_file}:${FUNCTEST_DIR}/conf/openstack.creds" + + +# Set iptables rule to allow forwarding return traffic for container +if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then + sudo iptables -I FORWARD -j RETURN +fi + +DEPLOY_TYPE=baremetal +[[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt +HOST_ARCH=$(uname -m) + +echo "Functest: Start Docker and prepare environment" + +echo "Functest: Download images that will be used by test cases" +images_dir="${HOME}/opnfv/functest/images" +download_script=${WORKSPACE}/functest/ci/download_images.sh +if [[ ! -f ${download_script} ]]; then + # to support Danube as well + wget https://git.opnfv.org/functest/plain/functest/ci/download_images.sh -O ${download_script} 2> ${redirect} +fi +chmod +x ${download_script} +${download_script} ${images_dir} ${DEPLOY_SCENARIO} ${HOST_ARCH} 2> ${redirect} + +images_vol="-v ${images_dir}:${FUNCTEST_DIR}/images" + +dir_result="${HOME}/opnfv/functest/results/${BRANCH##*/}" +mkdir -p ${dir_result} +sudo rm -rf ${dir_result}/* +results_vol="-v ${dir_result}:${FUNCTEST_DIR}/results" +custom_params= +test -f ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG} && custom_params=$(cat ${HOME}/opnfv/functest/custom/params_${DOCKER_TAG}) + +envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \ + -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \ + -e BUILD_TAG=${BUILD_TAG} -e DEPLOY_TYPE=${DEPLOY_TYPE}" + +if [[ ${INSTALLER_TYPE} == 'compass' && ${DEPLOY_SCENARIO} == *'os-nosdn-openo-ha'* ]]; then + ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" + openo_msb_port=${openo_msb_port:-80} + openo_msb_endpoint="$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \ + 'mysql -ucompass -pcompass -Dcompass -e "select package_config from cluster;" \ + | sed s/,/\\n/g | grep openo_ip | cut -d \" -f 4'):$openo_msb_port" + + envs=${env}" -e OPENO_MSB_ENDPOINT=${openo_msb_endpoint}" +fi + +volumes="${images_vol} ${results_vol} ${sshkey_vol} ${rc_file_vol} ${cacert_file_vol}" + + +tiers=(healthcheck smoke) +for tier in ${tiers[@]}; do + FUNCTEST_IMAGE=opnfv/functest-${tier} + echo "Functest: Pulling Functest Docker image ${FUNCTEST_IMAGE} ..." + docker pull ${FUNCTEST_IMAGE}>/dev/null + cmd="docker run ${envs} ${volumes} ${FUNCTEST_IMAGE}" + echo "Running Functest tier '${tier}'. CMD: ${cmd}" + ${cmd} +done diff --git a/jjb/functest/functest-daily-jobs.yml b/jjb/functest/functest-daily-jobs.yml index fdef6f483..f14ca758f 100644 --- a/jjb/functest/functest-daily-jobs.yml +++ b/jjb/functest/functest-daily-jobs.yml @@ -209,6 +209,16 @@ # <<: *master #-------------------------------- + alpine-pod: + - ericsson-virtual-pod1bl01: + slave-label: '{alpine-pod}' + installer: fuel + <<: *master + - huawei-virtual5: + slave-label: '{alpine-pod}' + installer: compass + <<: *master + testsuite: - 'suite': job-timeout: 60 @@ -217,6 +227,7 @@ jobs: - 'functest-{installer}-{pod}-{testsuite}-{stream}' + - 'functest-alpine-{installer}-{alpine-pod}-{testsuite}-{stream}' ################################ # job template @@ -269,6 +280,46 @@ description: "Built on $NODE_NAME" - 'functest-{testsuite}-builder' +- job-template: + name: 'functest-alpine-{installer}-{alpine-pod}-{testsuite}-{stream}' + + concurrent: true + + properties: + - logrotate-default + - throttle: + enabled: true + max-per-node: 1 + option: 'project' + + wrappers: + - build-name: + name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO' + - timeout: + timeout: '{job-timeout}' + abort: true + + parameters: + - project-parameter: + project: '{project}' + branch: '{branch}' + - '{installer}-defaults' + - '{slave-label}-defaults' + - 'functest-{testsuite}-parameter' + - string: + name: DEPLOY_SCENARIO + default: 'os-nosdn-nofeature-noha' + - functest-parameter: + gs-pathname: '{gs-pathname}' + + scm: + - git-scm + + builders: + - description-setter: + description: "Built on $NODE_NAME" + - 'functest-alpine-daily-builder' + ######################## # parameter macros ######################## @@ -360,6 +411,15 @@ - 'functest-exit' - builder: + name: functest-alpine-daily-builder + builders: + - shell: + !include-raw: + - ./functest-env-presetup.sh + - ../../utils/fetch_os_creds.sh + - ./functest-alpine.sh + +- builder: name: functest-daily builders: - shell: diff --git a/jjb/global/installer-params.yml b/jjb/global/installer-params.yml index ee154af03..5e07a11f9 100644 --- a/jjb/global/installer-params.yml +++ b/jjb/global/installer-params.yml @@ -75,8 +75,8 @@ description: 'Model to deploy (os|k8)' - string: name: OS_RELEASE - default: 'newton' - description: 'OpenStack release (mitaka|newton)' + default: 'ocata' + description: 'OpenStack release (mitaka|newton|ocata)' - string: name: EXTERNAL_NETWORK default: ext-net diff --git a/jjb/global/slave-params.yml b/jjb/global/slave-params.yml index 50859c46f..7a257f162 100644 --- a/jjb/global/slave-params.yml +++ b/jjb/global/slave-params.yml @@ -582,6 +582,15 @@ name: GIT_BASE default: https://gerrit.opnfv.org/gerrit/$PROJECT - parameter: + name: 'huawei-virtual5-defaults' + parameters: + - label: + name: SLAVE_LABEL + default: 'huawei-virtual5' + - string: + name: GIT_BASE + default: https://gerrit.opnfv.org/gerrit/$PROJECT +- parameter: name: 'huawei-virtual7-defaults' parameters: - node: @@ -935,6 +944,16 @@ default: https://gerrit.opnfv.org/gerrit/$PROJECT description: 'Git URL to use on this Jenkins Slave' - parameter: + name: 'ericsson-virtual-pod1bl01-defaults' + parameters: + - label: + name: SLAVE_LABEL + default: 'ericsson-virtual-pod1bl01' + - string: + name: GIT_BASE + default: https://gerrit.opnfv.org/gerrit/$PROJECT + description: 'Git URL to use on this Jenkins Slave' +- parameter: name: 'odl-netvirt-virtual-defaults' parameters: - label: diff --git a/jjb/joid/joid-daily-jobs.yml b/jjb/joid/joid-daily-jobs.yml index 13ea9b308..1ff260ac8 100644 --- a/jjb/joid/joid-daily-jobs.yml +++ b/jjb/joid/joid-daily-jobs.yml @@ -17,11 +17,6 @@ branch: '{stream}' disabled: false gs-pathname: '' - danube: &danube - stream: danube - branch: 'stable/{stream}' - disabled: false - gs-pathname: '/{stream}' #-------------------------------- # POD, INSTALLER, AND BRANCH MAPPING #-------------------------------- @@ -34,12 +29,6 @@ - virtual: slave-label: joid-virtual <<: *master - - baremetal: - slave-label: joid-baremetal - <<: *danube - - virtual: - slave-label: joid-virtual - <<: *danube #-------------------------------- # None-CI PODs #-------------------------------- @@ -62,7 +51,7 @@ - 'os-nosdn-lxd-noha': auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger' - 'os-odl_l2-nofeature-ha': - auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger' + auto-trigger-name: 'daily-trigger-disabled' - 'os-onos-nofeature-ha': auto-trigger-name: 'daily-trigger-disabled' - 'os-odl_l2-nofeature-noha': @@ -76,9 +65,11 @@ - 'os-ocl-nofeature-noha': auto-trigger-name: 'daily-trigger-disabled' - 'k8-nosdn-nofeature-noha': - auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger' + auto-trigger-name: 'daily-trigger-disabled' - 'k8-nosdn-lb-noha': auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger' + - 'k8-ovn-lb-noha': + auto-trigger-name: 'joid-{scenario}-{pod}-{stream}-trigger' jobs: - 'joid-{scenario}-{pod}-daily-{stream}' @@ -256,23 +247,6 @@ name: 'joid-os-nosdn-nofeature-ha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-nosdn-nofeature-ha trigger - branch: danube -- trigger: - name: 'joid-os-nosdn-nofeature-ha-baremetal-danube-trigger' - triggers: - - timed: '0 2 * * *' -- trigger: - name: 'joid-os-nosdn-nofeature-ha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-nofeature-ha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-nofeature-ha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-odl_l2-nofeature-ha trigger - branch: master - trigger: name: 'joid-os-odl_l2-nofeature-ha-baremetal-master-trigger' @@ -290,23 +264,6 @@ name: 'joid-os-odl_l2-nofeature-ha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-odl_l2-nofeature-ha trigger - branch: danube -- trigger: - name: 'joid-os-odl_l2-nofeature-ha-baremetal-danube-trigger' - triggers: - - timed: '0 7 * * *' -- trigger: - name: 'joid-os-odl_l2-nofeature-ha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-odl_l2-nofeature-ha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-odl_l2-nofeature-ha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-onos-nofeature-ha trigger - branch: master - trigger: name: 'joid-os-onos-nofeature-ha-baremetal-master-trigger' @@ -324,23 +281,6 @@ name: 'joid-os-onos-nofeature-ha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-onos-nofeature-ha trigger - branch: danube -- trigger: - name: 'joid-os-onos-nofeature-ha-baremetal-danube-trigger' - triggers: - - timed: '0 12 * * *' -- trigger: - name: 'joid-os-onos-nofeature-ha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-onos-nofeature-ha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-onos-nofeature-ha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-onos-sfc-ha trigger - branch: master - trigger: name: 'joid-os-onos-sfc-ha-baremetal-master-trigger' @@ -358,23 +298,6 @@ name: 'joid-os-onos-sfc-ha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-onos-sfc-ha trigger - branch: danube -- trigger: - name: 'joid-os-onos-sfc-ha-baremetal-danube-trigger' - triggers: - - timed: '0 17 * * *' -- trigger: - name: 'joid-os-onos-sfc-ha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-onos-sfc-ha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-onos-sfc-ha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-nosdn-lxd-noha trigger - branch: master - trigger: name: 'joid-os-nosdn-lxd-noha-baremetal-master-trigger' @@ -392,23 +315,6 @@ name: 'joid-os-nosdn-lxd-noha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-nosdn-lxd-noha trigger - branch: danube -- trigger: - name: 'joid-os-nosdn-lxd-noha-baremetal-danube-trigger' - triggers: - - timed: '0 22 * * *' -- trigger: - name: 'joid-os-nosdn-lxd-noha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-lxd-noha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-lxd-noha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-nosdn-lxd-ha trigger - branch: master - trigger: name: 'joid-os-nosdn-lxd-ha-baremetal-master-trigger' @@ -426,23 +332,6 @@ name: 'joid-os-nosdn-lxd-ha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-nosdn-lxd-ha trigger - branch: danube -- trigger: - name: 'joid-os-nosdn-lxd-ha-baremetal-danube-trigger' - triggers: - - timed: '0 10 * * *' -- trigger: - name: 'joid-os-nosdn-lxd-ha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-lxd-ha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-lxd-ha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # os-nosdn-nofeature-noha trigger - branch: master - trigger: name: 'joid-os-nosdn-nofeature-noha-baremetal-master-trigger' @@ -460,23 +349,6 @@ name: 'joid-os-nosdn-nofeature-noha-cengn-pod1-master-trigger' triggers: - timed: '' -# os-nosdn-nofeature-noha trigger - branch: danube -- trigger: - name: 'joid-os-nosdn-nofeature-noha-baremetal-danube-trigger' - triggers: - - timed: '0 4 * * *' -- trigger: - name: 'joid-os-nosdn-nofeature-noha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-nofeature-noha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-os-nosdn-nofeature-noha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # k8-nosdn-nofeature-noha trigger - branch: master - trigger: name: 'joid-k8-nosdn-nofeature-noha-baremetal-master-trigger' @@ -494,23 +366,6 @@ name: 'joid-k8-nosdn-nofeature-noha-cengn-pod1-master-trigger' triggers: - timed: '' -# k8-nosdn-nofeature-noha trigger - branch: danube -- trigger: - name: 'joid-k8-nosdn-nofeature-noha-baremetal-danube-trigger' - triggers: - - timed: '0 15 * * *' -- trigger: - name: 'joid-k8-nosdn-nofeature-noha-virtual-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-k8-nosdn-nofeature-noha-orange-pod1-danube-trigger' - triggers: - - timed: '' -- trigger: - name: 'joid-k8-nosdn-nofeature-noha-cengn-pod1-danube-trigger' - triggers: - - timed: '' # k8-nosdn-lb-noha trigger - branch: master - trigger: name: 'joid-k8-nosdn-lb-noha-baremetal-master-trigger' @@ -528,20 +383,20 @@ name: 'joid-k8-nosdn-lb-noha-cengn-pod1-master-trigger' triggers: - timed: '' -# k8-nosdn-lb-noha trigger - branch: danube +# k8-ovn-lb-noha trigger - branch: master - trigger: - name: 'joid-k8-nosdn-lb-noha-baremetal-danube-trigger' + name: 'joid-k8-ovn-lb-noha-baremetal-master-trigger' triggers: - - timed: '0 20 * * *' + - timed: '5 17 * * *' - trigger: - name: 'joid-k8-nosdn-lb-noha-virtual-danube-trigger' + name: 'joid-k8-ovn-lb-noha-virtual-master-trigger' triggers: - timed: '' - trigger: - name: 'joid-k8-nosdn-lb-noha-orange-pod1-danube-trigger' + name: 'joid-k8-ovn-lb-noha-orange-pod1-master-trigger' triggers: - timed: '' - trigger: - name: 'joid-k8-nosdn-lb-noha-cengn-pod1-danube-trigger' + name: 'joid-k8-ovn-lb-noha-cengn-pod1-master-trigger' triggers: - timed: '' diff --git a/jjb/orchestra/orchestra-daily-jobs.yml b/jjb/orchestra/orchestra-daily-jobs.yml new file mode 100644 index 000000000..6baaab896 --- /dev/null +++ b/jjb/orchestra/orchestra-daily-jobs.yml @@ -0,0 +1,98 @@ +################################### +# job configuration for orchestra +################################### +- project: + name: 'orchestra-daily-jobs' + + project: 'orchestra' + +#-------------------------------- +# BRANCH ANCHORS +#-------------------------------- + master: &master + stream: master + branch: '{stream}' + gs-pathname: '' + disabled: false + +#------------------------------------------------------- +# POD, INSTALLER, AND BRANCH MAPPING +#------------------------------------------------------- + pod: + - virtual: + slave-label: 'joid-virtual' + os-version: 'xenial' + <<: *master + + jobs: + - 'orchestra-{pod}-daily-{stream}' + +################################ +# job template +################################ +- job-template: + name: 'orchestra-{pod}-daily-{stream}' + + project-type: multijob + + disabled: '{obj:disabled}' + + concurrent: false + + properties: + - logrotate-default + - throttle: + enabled: true + max-total: 1 + max-per-node: 1 + option: 'project' + + scm: + - git-scm + + wrappers: + - ssh-agent-wrapper + + - timeout: + timeout: 240 + fail: true + + triggers: + - timed: '@daily' + + parameters: + - project-parameter: + project: '{project}' + branch: '{branch}' + - string: + name: DEPLOY_SCENARIO + default: os-nosdn-openbaton-ha + - '{slave-label}-defaults' + + builders: + - description-setter: + description: "Built on $NODE_NAME" + - multijob: + name: deploy + condition: SUCCESSFUL + projects: + - name: 'joid-deploy-{pod}-daily-{stream}' + current-parameters: false + predefined-parameters: | + DEPLOY_SCENARIO=os-nosdn-openbaton-ha + COMPASS_OS_VERSION=xenial + node-parameters: true + kill-phase-on: FAILURE + abort-all-job: true + - multijob: + name: functest + condition: SUCCESSFUL + projects: + - name: 'functest-joid-{pod}-daily-{stream}' + current-parameters: false + predefined-parameters: | + DEPLOY_SCENARIO=os-nosdn-openbaton-ha + FUNCTEST_SUITE_NAME=orchestra_ims + node-parameters: true + kill-phase-on: NEVER + abort-all-job: true diff --git a/jjb/orchestra/orchestra-project-jobs.yml b/jjb/orchestra/orchestra-project-jobs.yml new file mode 100644 index 000000000..0f0c0f6c9 --- /dev/null +++ b/jjb/orchestra/orchestra-project-jobs.yml @@ -0,0 +1,50 @@ +- project: + + name: orchestra-project + + project: 'orchestra' + + stream: + - master: + branch: '{stream}' + gs-pathname: '' + + jobs: + - 'orchestra-build-{stream}' + +- job-template: + name: 'orchestra-build-{stream}' + + concurrent: true + + properties: + - logrotate-default + - throttle: + enabled: true + max-total: 1 + max-per-node: 1 + option: 'project' + + parameters: + - project-parameter: + project: '{project}' + branch: '{branch}' + + scm: + - git-scm + + triggers: + - timed: 'H 23 * * *' + + builders: + - 'orchestra-build-macro' + +- builder: + name: 'orchestra-build-macro' + builders: + - shell: | + #!/bin/bash + + echo "Hello world!" + + diff --git a/jjb/releng/opnfv-docker-arm.yml b/jjb/releng/opnfv-docker-arm.yml index 417fc702c..7502b17a1 100644 --- a/jjb/releng/opnfv-docker-arm.yml +++ b/jjb/releng/opnfv-docker-arm.yml @@ -65,6 +65,10 @@ default: "" description: "Release version, e.g. 1.0, 2.0, 3.0" - string: + name: DOCKER_DIR + default: "docker" + description: "Directory containing files needed by the Dockerfile" + - string: name: DOCKERFILE default: "Dockerfile.aarch64" description: "Dockerfile to use for creating the image." diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh index ebd0c9f3d..0de3df28e 100644 --- a/jjb/releng/opnfv-docker.sh +++ b/jjb/releng/opnfv-docker.sh @@ -54,7 +54,7 @@ if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then done fi -cd $WORKSPACE/docker +cd $WORKSPACE/$DOCKER_DIR HOST_ARCH=$(uname -m) if [ ! -f "${DOCKERFILE}" ]; then # If this is expected to be a Dockerfile for other arch than x86 diff --git a/jjb/releng/opnfv-docker.yml b/jjb/releng/opnfv-docker.yml index 095ba4129..fa9c441e8 100644 --- a/jjb/releng/opnfv-docker.yml +++ b/jjb/releng/opnfv-docker.yml @@ -23,62 +23,97 @@ other-receivers: &other-receivers receivers: '' - project: + dockerfile: "Dockerfile" + dockerdir: "docker" + + # This is the dockerhub repo the image will be pushed to as + # 'opnfv/{dockerrepo}. See: DOCKER_REPO_NAME parameter. + # 'project' is the OPNFV repo we expect to contain the Dockerfile + dockerrepo: # projects with jobs for master - 'releng-anteater': + project: 'releng-anteater' <<: *master <<: *other-receivers - 'bottlenecks': + project: 'bottlenecks' <<: *master <<: *other-receivers - 'cperf': + project: 'cperf' <<: *master <<: *other-receivers - 'dovetail': + project: 'dovetail' <<: *master <<: *other-receivers - 'functest': + project: 'functest' <<: *master <<: *functest-receivers - 'qtip': + project: 'qtip' <<: *master <<: *other-receivers - - 'storperf': + - 'storperf-master': + project: 'storperf' + dockerdir: 'docker/storperf-master' + <<: *master + <<: *other-receivers + - 'storperf-httpfrontend': + project: 'storperf' + dockerdir: 'docker/storperf-httpfrontend' + <<: *master + <<: *other-receivers + - 'storperf-reporting': + project: 'storperf' + dockerdir: 'docker/storperf-reporting' <<: *master <<: *other-receivers - 'yardstick': + project: 'yardstick' <<: *master <<: *other-receivers # projects with jobs for stable - 'bottlenecks': + project: 'bottlenecks' <<: *danube <<: *other-receivers - 'functest': + project: 'functest' <<: *danube <<: *functest-receivers - 'qtip': + project: 'qtip' <<: *danube <<: *other-receivers - 'storperf': + project: 'storperf' <<: *danube <<: *other-receivers - 'yardstick': + project: 'yardstick' <<: *danube <<: *other-receivers jobs: - - '{project}-docker-build-push-{stream}' + - "{dockerrepo}-docker-build-push-{stream}" - project: name: opnfv-monitor-docker # projects which only monitor dedicated file or path + dockerfile: "Dockerfile" + dockerdir: "docker" + project: # projects with jobs for master - 'daisy': + dockerrepo: 'daisy' <<: *master - 'escalator': + dockerrepo: 'escalator' <<: *master jobs: @@ -88,7 +123,7 @@ # job templates ######################## - job-template: - name: '{project}-docker-build-push-{stream}' + name: '{dockerrepo}-docker-build-push-{stream}' disabled: '{obj:disabled}' @@ -103,9 +138,13 @@ description: "To enable/disable pushing the image to Dockerhub." - string: name: DOCKER_REPO_NAME - default: "opnfv/{project}" + default: "opnfv/{dockerrepo}" description: "Dockerhub repo to be pushed to." - string: + name: DOCKER_DIR + default: "{dockerdir}" + description: "Directory containing files needed by the Dockerfile" + - string: name: COMMIT_ID default: "" description: "commit id to make a snapshot docker image" @@ -115,7 +154,7 @@ description: "Release version, e.g. 1.0, 2.0, 3.0" - string: name: DOCKERFILE - default: "Dockerfile" + default: "{dockerfile}" description: "Dockerfile to use for creating the image." scm: diff --git a/jjb/yardstick/yardstick-daily.sh b/jjb/yardstick/yardstick-daily.sh index cf37ac262..56d087473 100755 --- a/jjb/yardstick/yardstick-daily.sh +++ b/jjb/yardstick/yardstick-daily.sh @@ -3,6 +3,7 @@ set -e [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null" rc_file_vol="" +cacert_file_vol="" sshkey="" if [[ ${INSTALLER_TYPE} == 'apex' ]]; then @@ -23,6 +24,10 @@ if [[ ${INSTALLER_TYPE} == 'joid' ]]; then rc_file_vol="-v $LAB_CONFIG/admin-openrc:/etc/yardstick/openstack.creds" # If dev lab, credentials may not be the default ones, just provide a path to put them into docker # replace the default one by the customized one provided by jenkins config +elif [[ ${INSTALLER_TYPE} == 'compass' && ${BRANCH} == 'master' ]]; then + cacert_file_vol="-v ${HOME}/os_cacert:/etc/yardstick/os_cacert" + echo "export OS_CACERT=/etc/yardstick/os_cacert" >> ${HOME}/opnfv-openrc.sh + rc_file_vol="-v ${HOME}/opnfv-openrc.sh:/etc/yardstick/openstack.creds" else rc_file_vol="-v ${HOME}/opnfv-openrc.sh:/etc/yardstick/openstack.creds" fi @@ -50,7 +55,7 @@ sudo rm -rf ${dir_result}/* map_log_dir="-v ${dir_result}:/tmp/yardstick" # Run docker -cmd="sudo docker run ${opts} ${envs} ${rc_file_vol} ${map_log_dir} ${sshkey} opnfv/yardstick:${DOCKER_TAG} \ +cmd="sudo docker run ${opts} ${envs} ${rc_file_vol} ${cacert_file_vol} ${map_log_dir} ${sshkey} opnfv/yardstick:${DOCKER_TAG} \ exec_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SCENARIO_SUITE_NAME}" echo "Yardstick: Running docker cmd: ${cmd}" ${cmd} diff --git a/prototypes/bifrost/playbooks/opnfv-virtual.yaml b/prototypes/bifrost/playbooks/opnfv-virtual.yaml index 94de628a6..3cba98b6b 100644 --- a/prototypes/bifrost/playbooks/opnfv-virtual.yaml +++ b/prototypes/bifrost/playbooks/opnfv-virtual.yaml @@ -48,6 +48,7 @@ dib_os_element: "{{ ipa_dib_os_element|default('debian') }}" dib_os_release: "jessie" dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}" + dib_notmpfs: true when: create_ipa_image | bool == true - role: bifrost-create-dib-image dib_imagetype: "qcow2" @@ -57,6 +58,7 @@ extra_dib_elements: "{{ lookup('env', 'EXTRA_DIB_ELEMENTS') | default('') }}" dib_elements: "vm enable-serial-console simple-init devuser growroot {{ extra_dib_elements }}" dib_packages: "{{ lookup('env', 'DIB_OS_PACKAGES') }}" + dib_notmpfs: true when: create_image_via_dib | bool == true and transform_boot_image | bool == false - role: bifrost-keystone-client-config user: "{{ ansible_env.SUDO_USER }}" diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/app.js b/utils/test/testapi/3rd_party/static/testapi-ui/app.js index 8c701c36c..bb31ab081 100644 --- a/utils/test/testapi/3rd_party/static/testapi-ui/app.js +++ b/utils/test/testapi/3rd_party/static/testapi-ui/app.js @@ -54,8 +54,8 @@ controller: 'ResultsController as ctrl' }). state('userResults', { - url: 'user_results', - templateUrl: '/testapi-ui/components/results/results.html', + url: '/user_results', + templateUrl: 'testapi-ui/components/results/results.html', controller: 'ResultsController as ctrl' }). state('resultsDetail', { @@ -66,7 +66,7 @@ }). state('profile', { url: '/profile', - templateUrl: '/testapi-ui/components/profile/profile.html', + templateUrl: 'testapi-ui/components/profile/profile.html', controller: 'ProfileController as ctrl' }). state('authFailure', { diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html index 3056e1dbe..2ae5339a0 100644 --- a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html +++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/results.html @@ -1,6 +1,23 @@ <h3>{{ctrl.pageHeader}}</h3> <p>{{ctrl.pageParagraph}}</p> - +<form class="form-inline" ng-show="ctrl.isUserResults"> +<h4>Upload Results</h4> +<div class="form-group col-m-3"> + <input class="form-contrl btn btn-default" type = "file" file-model = "resultFile"/> +</div> +<div class="checkbox col-m-1"> + <label> + <input type="checkbox" ng-model="ctrl.isPublic">public + </label> +</div> +<div class="form-group col-m-3"> + <button class="btn btn-primary" ng-click = "ctrl.uploadFile()">upload result</button> +</div> +<div> +<lable>{{ctrl.uploadState}}</label> +</div> +</form> +<div class="row" style="margin-bottom:24px;"></div> <div class="result-filters"> <h4>Filters</h4> <div class="row"> @@ -41,7 +58,6 @@ <div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div> <div cg-busy="{promise:ctrl.resultsRequest,message:'Loading'}"></div> - <div ng-show="ctrl.data" class="results-table"> <table ng-data="ctrl.data.result" ng-show="ctrl.data" class="table table-striped table-hover"> <thead> diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js index 9e3540da5..cc6cc0b6e 100644 --- a/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js +++ b/utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js @@ -19,6 +19,24 @@ .module('testapiApp') .controller('ResultsController', ResultsController); + angular + .module('testapiApp') + .directive('fileModel', ['$parse', function ($parse) { + return { + restrict: 'A', + link: function(scope, element, attrs) { + var model = $parse(attrs.fileModel); + var modelSetter = model.assign; + + element.bind('change', function(){ + scope.$apply(function(){ + modelSetter(scope, element[0].files[0]); + }); + }); + } + }; + }]); + ResultsController.$inject = [ '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert' ]; @@ -32,6 +50,7 @@ raiseAlert) { var ctrl = this; + ctrl.uploadFile=uploadFile; ctrl.update = update; ctrl.open = open; ctrl.clearFilters = clearFilters; @@ -76,6 +95,8 @@ ctrl.format = 'yyyy-MM-dd'; /** Check to see if this page should display user-specific results. */ + // ctrl.isUserResults = $state.current.name === 'userResults'; + // need auth to browse ctrl.isUserResults = $state.current.name === 'userResults'; // Should only be on user-results-page if authenticated. @@ -91,14 +112,49 @@ 'The most recently uploaded community test results are listed ' + 'here.'; + ctrl.uploadState = ''; + + ctrl.isPublic = false; + if (ctrl.isUserResults) { ctrl.authRequest = $scope.auth.doSignCheck() .then(ctrl.update); - ctrl.getUserProducts(); + // ctrl.getUserProducts(); } else { ctrl.update(); } + + function uploadFileToUrl(file, uploadUrl){ + var fd = new FormData(); + fd.append('file', file); + fd.append('public', ctrl.isPublic) + + $http.post(uploadUrl, fd, { + transformRequest: angular.identity, + headers: {'Content-Type': undefined} + }) + + .success(function(data){ + var id = data.href.substr(data.href.lastIndexOf('/')+1); + ctrl.uploadState = "Upload succeed. Result id is " + id; + ctrl.update(); + }) + + .error(function(data, status){ + ctrl.uploadState = "Upload failed. Error code is " + status; + }); + } + + function uploadFile(){ + var file = $scope.resultFile; + console.log('file is ' ); + console.dir(file); + + var uploadUrl = testapiApiUrl + "/results/upload"; + uploadFileToUrl(file, uploadUrl); + }; + /** * This will contact the TestAPI API to get a listing of test run * results. diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html b/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html index f2c49e86f..85c33b68d 100644 --- a/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html +++ b/utils/test/testapi/3rd_party/static/testapi-ui/shared/header/header.html @@ -33,6 +33,7 @@ TestAPI </ul> <ul class="nav navbar-nav navbar-right"> <li ng-class="{ active: header.isActive('/user_results')}" ng-if="auth.isAuthenticated"><a ui-sref="userResults">My Results</a></li> + <!-- <li ng-if="auth.isAuthenticated" ng-class="{ active: header.isCatalogActive('user')}" class="dropdown" uib-dropdown> <a role="button" class="dropdown-toggle" uib-dropdown-toggle> My Catalog <strong class="caret"></strong> @@ -42,6 +43,7 @@ TestAPI <li><a ui-sref="userProducts">My Products</a></li> </ul> </li> + --> <li ng-class="{ active: header.isActive('/profile')}" ng-if="auth.isAuthenticated"><a ui-sref="profile">Profile</a></li> <li ng-if="auth.isAuthenticated"><a href="" ng-click="auth.doSignOut()">Sign Out</a></li> <li ng-if="!auth.isAuthenticated"><a href="" ng-click="auth.doSignIn()">Sign In / Sign Up</a></li> diff --git a/utils/test/testapi/etc/config.ini b/utils/test/testapi/etc/config.ini index 9ae25209d..435188df7 100644 --- a/utils/test/testapi/etc/config.ini +++ b/utils/test/testapi/etc/config.ini @@ -12,7 +12,7 @@ url = http://localhost:8000/api/v1 port = 8000 # Number of results for one page (integer value) -#results_per_page = 20 +results_per_page = 20 # With debug_on set to true, error traces will be shown in HTTP responses debug = True diff --git a/utils/test/testapi/opnfv_testapi/cmd/server.py b/utils/test/testapi/opnfv_testapi/cmd/server.py index 545d5e367..a5ac5eb6b 100644 --- a/utils/test/testapi/opnfv_testapi/cmd/server.py +++ b/utils/test/testapi/opnfv_testapi/cmd/server.py @@ -29,40 +29,18 @@ TODOs : """ -import argparse -import sys - -import motor import tornado.ioloop -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF from opnfv_testapi.router import url_mappings from opnfv_testapi.tornado_swagger import swagger -CONF = None - - -def parse_config(argv=[]): - global CONF - parser = argparse.ArgumentParser() - parser.add_argument("-c", "--config-file", dest='config_file', - help="Config file location") - args = parser.parse_args(argv) - if args.config_file: - config.Config.CONFIG = args.config_file - CONF = config.Config() - - -def get_db(): - return motor.MotorClient(CONF.mongo_url)[CONF.mongo_dbname] - def make_app(): swagger.docs(base_url=CONF.swagger_base_url, static_path=CONF.static_path) return swagger.Application( url_mappings.mappings, - db=get_db(), debug=CONF.api_debug, auth=CONF.api_authenticate, cookie_secret='opnfv-testapi', @@ -70,7 +48,6 @@ def make_app(): def main(): - parse_config(sys.argv[1:]) application = make_app() application.listen(CONF.api_port) tornado.ioloop.IOLoop.current().start() diff --git a/utils/test/testapi/opnfv_testapi/common/check.py b/utils/test/testapi/opnfv_testapi/common/check.py index 67e8fbd40..24ba876a9 100644 --- a/utils/test/testapi/opnfv_testapi/common/check.py +++ b/utils/test/testapi/opnfv_testapi/common/check.py @@ -13,6 +13,7 @@ from tornado import web from opnfv_testapi.common import message from opnfv_testapi.common import raises +from opnfv_testapi.db import api as dbapi def authenticate(method): @@ -26,7 +27,7 @@ def authenticate(method): except KeyError: raises.Unauthorized(message.unauthorized()) query = {'access_token': token} - check = yield self._eval_db_find_one(query, 'tokens') + check = yield dbapi.db_find_one('tokens', query) if not check: raises.Forbidden(message.invalid_token()) ret = yield gen.coroutine(method)(self, *args, **kwargs) @@ -38,7 +39,7 @@ def not_exist(xstep): @functools.wraps(xstep) def wrap(self, *args, **kwargs): query = kwargs.get('query') - data = yield self._eval_db_find_one(query) + data = yield dbapi.db_find_one(self.table, query) if not data: raises.NotFound(message.not_found(self.table, query)) ret = yield gen.coroutine(xstep)(self, data, *args, **kwargs) @@ -78,7 +79,7 @@ def carriers_exist(xstep): carriers = kwargs.pop('carriers', {}) if carriers: for table, query in carriers: - exist = yield self._eval_db_find_one(query(), table) + exist = yield dbapi.db_find_one(table, query()) if not exist: raises.Forbidden(message.not_found(table, query())) ret = yield gen.coroutine(xstep)(self, *args, **kwargs) @@ -91,7 +92,7 @@ def new_not_exists(xstep): def wrap(self, *args, **kwargs): query = kwargs.get('query') if query: - to_data = yield self._eval_db_find_one(query()) + to_data = yield dbapi.db_find_one(self.table, query()) if to_data: raises.Forbidden(message.exist(self.table, query())) ret = yield gen.coroutine(xstep)(self, *args, **kwargs) @@ -105,7 +106,7 @@ def updated_one_not_exist(xstep): db_keys = kwargs.pop('db_keys', []) query = self._update_query(db_keys, data) if query: - to_data = yield self._eval_db_find_one(query) + to_data = yield dbapi.db_find_one(self.table, query) if to_data: raises.Forbidden(message.exist(self.table, query)) ret = yield gen.coroutine(xstep)(self, data, *args, **kwargs) diff --git a/utils/test/testapi/opnfv_testapi/common/config.py b/utils/test/testapi/opnfv_testapi/common/config.py index f73c0abf2..4cd53c619 100644 --- a/utils/test/testapi/opnfv_testapi/common/config.py +++ b/utils/test/testapi/opnfv_testapi/common/config.py @@ -8,14 +8,16 @@ # feng.xiaowei@zte.com.cn remove prepare_put_request 5-30-2016 ############################################################################## import ConfigParser +import argparse import os +import sys class Config(object): - CONFIG = None def __init__(self): - self.file = self.CONFIG if self.CONFIG else self._default_config() + self.config_file = None + self._set_config_file() self._parse() self._parse_per_page() self.static_path = os.path.join( @@ -24,11 +26,11 @@ class Config(object): 'static') def _parse(self): - if not os.path.exists(self.file): - raise Exception("%s not found" % self.file) + if not os.path.exists(self.config_file): + raise Exception("%s not found" % self.config_file) config = ConfigParser.RawConfigParser() - config.read(self.file) + config.read(self.config_file) self._parse_section(config) def _parse_section(self, config): @@ -53,8 +55,24 @@ class Config(object): value = False return value - @staticmethod - def _default_config(): + def _set_config_file(self): + if not self._set_sys_config_file(): + self._set_default_config_file() + + def _set_sys_config_file(self): + parser = argparse.ArgumentParser() + parser.add_argument("-c", "--config-file", dest='config_file', + help="Config file location", metavar="FILE") + args, _ = parser.parse_known_args(sys.argv) + try: + self.config_file = args.config_file + finally: + return self.config_file is not None + + def _set_default_config_file(self): is_venv = os.getenv('VIRTUAL_ENV') - return os.path.join('/' if not is_venv else is_venv, - 'etc/opnfv_testapi/config.ini') + self.config_file = os.path.join('/' if not is_venv else is_venv, + 'etc/opnfv_testapi/config.ini') + + +CONF = Config() diff --git a/utils/test/testapi/opnfv_testapi/common/message.py b/utils/test/testapi/opnfv_testapi/common/message.py index 98536ff4b..951cbaf9c 100644 --- a/utils/test/testapi/opnfv_testapi/common/message.py +++ b/utils/test/testapi/opnfv_testapi/common/message.py @@ -10,6 +10,10 @@ not_found_base = 'Could Not Found' exist_base = 'Already Exists' +def key_error(key): + return "KeyError: '{}'".format(key) + + def no_body(): return 'No Body' diff --git a/utils/test/testapi/opnfv_testapi/db/__init__.py b/utils/test/testapi/opnfv_testapi/db/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/db/__init__.py diff --git a/utils/test/testapi/opnfv_testapi/db/api.py b/utils/test/testapi/opnfv_testapi/db/api.py new file mode 100644 index 000000000..c057480d4 --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/db/api.py @@ -0,0 +1,38 @@ +import motor + +from opnfv_testapi.common.config import CONF + +DB = motor.MotorClient(CONF.mongo_url)[CONF.mongo_dbname] + + +def db_update(collection, query, update_req): + return _eval_db(collection, 'update', query, update_req, check_keys=False) + + +def db_delete(collection, query): + return _eval_db(collection, 'remove', query) + + +def db_aggregate(collection, pipelines): + return _eval_db(collection, 'aggregate', pipelines, allowDiskUse=True) + + +def db_list(collection, query): + return _eval_db(collection, 'find', query) + + +def db_save(collection, data): + return _eval_db(collection, 'insert', data, check_keys=False) + + +def db_find_one(collection, query): + return _eval_db(collection, 'find_one', query) + + +def _eval_db(collection, method, *args, **kwargs): + exec_collection = DB.__getattr__(collection) + return exec_collection.__getattribute__(method)(*args, **kwargs) + + +def _eval_db_find_one(query, table=None): + return _eval_db(table, 'find_one', query) diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py index c7fed8f17..8a3a2db38 100644 --- a/utils/test/testapi/opnfv_testapi/resources/handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py @@ -20,8 +20,8 @@ # feng.xiaowei@zte.com.cn remove DashboardHandler 5-30-2016 ############################################################################## -from datetime import datetime import json +from datetime import datetime from tornado import gen from tornado import web @@ -29,6 +29,7 @@ from tornado import web from opnfv_testapi.common import check from opnfv_testapi.common import message from opnfv_testapi.common import raises +from opnfv_testapi.db import api as dbapi from opnfv_testapi.resources import models from opnfv_testapi.tornado_swagger import swagger @@ -38,7 +39,6 @@ DEFAULT_REPRESENTATION = "application/json" class GenericApiHandler(web.RequestHandler): def __init__(self, application, request, **kwargs): super(GenericApiHandler, self).__init__(application, request, **kwargs) - self.db = self.settings["db"] self.json_args = None self.table = None self.table_cls = None @@ -90,8 +90,7 @@ class GenericApiHandler(web.RequestHandler): if self.table != 'results': data.creation_date = datetime.now() - _id = yield self._eval_db(self.table, 'insert', data.format(), - check_keys=False) + _id = yield dbapi.db_save(self.table, data.format()) if 'name' in self.json_args: resource = data.name else: @@ -107,17 +106,17 @@ class GenericApiHandler(web.RequestHandler): per_page = kwargs.get('per_page', 0) if query is None: query = {} - cursor = self._eval_db(self.table, 'find', query) - records_count = yield cursor.count() - total_pages = self._calc_total_pages(records_count, - last, - page, - per_page) + + total_pages = 0 + if page > 0: + cursor = dbapi.db_list(self.table, query) + records_count = yield cursor.count() + total_pages = self._calc_total_pages(records_count, + last, + page, + per_page) pipelines = self._set_pipelines(query, sort, last, page, per_page) - cursor = self._eval_db(self.table, - 'aggregate', - pipelines, - allowDiskUse=True) + cursor = dbapi.db_aggregate(self.table, pipelines) data = list() while (yield cursor.fetch_next): data.append(self.format_data(cursor.next_object())) @@ -125,7 +124,7 @@ class GenericApiHandler(web.RequestHandler): res = {self.table: data} else: res = res_op(data, *args) - if total_pages > 0: + if page > 0: res.update({ 'pagination': { 'current_page': kwargs.get('page'), @@ -140,12 +139,10 @@ class GenericApiHandler(web.RequestHandler): if (records_count > last) and (last > 0): records_nr = last - total_pages = 0 - if page > 0: - total_pages, remainder = divmod(records_nr, per_page) - if remainder > 0: - total_pages += 1 - if page > total_pages: + total_pages, remainder = divmod(records_nr, per_page) + if remainder > 0: + total_pages += 1 + if page > 1 and page > total_pages: raises.BadRequest( 'Request page > total_pages [{}]'.format(total_pages)) return total_pages @@ -175,7 +172,7 @@ class GenericApiHandler(web.RequestHandler): @check.authenticate @check.not_exist def _delete(self, data, query=None): - yield self._eval_db(self.table, 'remove', query) + yield dbapi.db_delete(self.table, query) self.finish_request() @check.authenticate @@ -185,8 +182,7 @@ class GenericApiHandler(web.RequestHandler): def _update(self, data, query=None, **kwargs): data = self.table_cls.from_dict(data) update_req = self._update_requests(data) - yield self._eval_db(self.table, 'update', query, update_req, - check_keys=False) + yield dbapi.db_update(self.table, query, update_req) update_req['_id'] = str(data._id) self.finish_request(update_req) @@ -229,23 +225,6 @@ class GenericApiHandler(web.RequestHandler): query[key] = new return query if not equal else dict() - def _eval_db(self, table, method, *args, **kwargs): - exec_collection = self.db.__getattr__(table) - return exec_collection.__getattribute__(method)(*args, **kwargs) - - def _eval_db_find_one(self, query, table=None): - if table is None: - table = self.table - return self._eval_db(table, 'find_one', query) - - def db_save(self, collection, data): - self._eval_db(collection, 'insert', data, check_keys=False) - - def db_find_one(self, query, collection=None): - if not collection: - collection = self.table - return self._eval_db(collection, 'find_one', query) - class VersionHandler(GenericApiHandler): @swagger.operation(nickname='listAllVersions') diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py index 1773216c0..2bf1792f2 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py @@ -6,19 +6,20 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import logging from datetime import datetime from datetime import timedelta +import json from bson import objectid -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF from opnfv_testapi.common import message from opnfv_testapi.common import raises from opnfv_testapi.resources import handlers from opnfv_testapi.resources import result_models from opnfv_testapi.tornado_swagger import swagger - -CONF = config.Config() +from opnfv_testapi.ui.auth import constants as auth_const class GenericResultHandler(handlers.GenericApiHandler): @@ -40,6 +41,7 @@ class GenericResultHandler(handlers.GenericApiHandler): query = dict() date_range = dict() + query['public'] = {'$not': {'$eq': 'false'}} for k in self.request.query_arguments.keys(): v = self.get_query_argument(k) if k == 'project' or k == 'pod' or k == 'case': @@ -56,10 +58,24 @@ class GenericResultHandler(handlers.GenericApiHandler): date_range.update({'$gte': str(v)}) elif k == 'to': date_range.update({'$lt': str(v)}) - elif k != 'last' and k != 'page': + elif k == 'signed': + openid = self.get_secure_cookie(auth_const.OPENID) + role = self.get_secure_cookie(auth_const.ROLE) + logging.info('role:%s', role) + if role: + del query['public'] + if role != "reviewer": + query['user'] = openid + elif k not in ['last', 'page', 'descend']: query[k] = v if date_range: query['start_date'] = date_range + + # if $lt is not provided, + # empty/None/null/'' start_date will also be returned + if 'start_date' in query and '$lt' not in query['start_date']: + query['start_date'].update({'$lt': str(datetime.now())}) + return query @@ -84,9 +100,10 @@ class ResultsCLHandler(GenericResultHandler): - criteria : the global criteria status passed or failed - trust_indicator : evaluate the stability of the test case to avoid running systematically long and stable test case + - signed : get logined user result GET /results/project=functest&case=vPing&version=Arno-R1 \ - &pod=pod_name&period=15 + &pod=pod_name&period=15&signed @return 200: all test results consist with query, empty list if no result is found @rtype: L{TestResults} @@ -146,18 +163,31 @@ class ResultsCLHandler(GenericResultHandler): @type trust_indicator: L{float} @in trust_indicator: query @required trust_indicator: False + @param signed: user results or all results + @type signed: L{string} + @in signed: query + @required signed: False + @param descend: true, newest2oldest; false, oldest2newest + @type descend: L{string} + @in descend: query + @required descend: False """ - limitations = {'sort': {'start_date': -1}} - last = self.get_query_argument('last', 0) - if last is not None: - last = self.get_int('last', last) - limitations.update({'last': last}) - - page = self.get_query_argument('page', None) - if page is not None: - page = self.get_int('page', page) - limitations.update({'page': page, - 'per_page': CONF.api_results_per_page}) + def descend_limit(): + descend = self.get_query_argument('descend', 'true') + return -1 if descend.lower() == 'true' else 1 + + def last_limit(): + return self.get_int('last', self.get_query_argument('last', 0)) + + def page_limit(): + return self.get_int('page', self.get_query_argument('page', 0)) + + limitations = { + 'sort': {'_id': descend_limit()}, + 'last': last_limit(), + 'page': page_limit(), + 'per_page': CONF.api_results_per_page + } self._list(query=self.set_query(), **limitations) @@ -173,6 +203,9 @@ class ResultsCLHandler(GenericResultHandler): @raise 404: pod/project/testcase not exist @raise 400: body/pod_name/project_name/case_name not provided """ + self._post() + + def _post(self): def pod_query(): return {'name': self.json_args.get('pod_name')} @@ -187,9 +220,39 @@ class ResultsCLHandler(GenericResultHandler): carriers = [('pods', pod_query), ('projects', project_query), ('testcases', testcase_query)] + self._create(miss_fields=miss_fields, carriers=carriers) +class ResultsUploadHandler(ResultsCLHandler): + @swagger.operation(nickname="uploadTestResult") + def post(self): + """ + @description: upload and create a test result + @param body: result to be created + @type body: L{ResultCreateRequest} + @in body: body + @rtype: L{CreateResponse} + @return 200: result is created. + @raise 404: pod/project/testcase not exist + @raise 400: body/pod_name/project_name/case_name not provided + """ + logging.info('file upload') + fileinfo = self.request.files['file'][0] + is_public = self.get_body_argument('public') + logging.warning('public:%s', is_public) + logging.info('results is :%s', fileinfo['filename']) + logging.info('results is :%s', fileinfo['body']) + self.json_args = json.loads(fileinfo['body']).copy() + self.json_args['public'] = is_public + + openid = self.get_secure_cookie(auth_const.OPENID) + if openid: + self.json_args['user'] = openid + + super(ResultsUploadHandler, self)._post() + + class ResultsGURHandler(GenericResultHandler): @swagger.operation(nickname='getTestResultById') def get(self, result_id): diff --git a/utils/test/testapi/opnfv_testapi/resources/result_models.py b/utils/test/testapi/opnfv_testapi/resources/result_models.py index 62a6dacff..890bf8220 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/result_models.py @@ -54,6 +54,8 @@ class ResultCreateRequest(models.ModelBase): build_tag=None, scenario=None, criteria=None, + user=None, + public="true", trust_indicator=None): self.pod_name = pod_name self.project_name = project_name @@ -66,6 +68,8 @@ class ResultCreateRequest(models.ModelBase): self.build_tag = build_tag self.scenario = scenario self.criteria = criteria + self.user = user + self.public = public self.trust_indicator = trust_indicator if trust_indicator else TI(0) @@ -89,7 +93,7 @@ class TestResult(models.ModelBase): pod_name=None, installer=None, version=None, start_date=None, stop_date=None, details=None, build_tag=None, scenario=None, criteria=None, - trust_indicator=None): + user=None, public="true", trust_indicator=None): self._id = _id self.case_name = case_name self.project_name = project_name @@ -102,6 +106,8 @@ class TestResult(models.ModelBase): self.build_tag = build_tag self.scenario = scenario self.criteria = criteria + self.user = user + self.public = public self.trust_indicator = trust_indicator @staticmethod diff --git a/utils/test/testapi/opnfv_testapi/router/url_mappings.py b/utils/test/testapi/opnfv_testapi/router/url_mappings.py index a2312de09..562fa5efe 100644 --- a/utils/test/testapi/opnfv_testapi/router/url_mappings.py +++ b/utils/test/testapi/opnfv_testapi/router/url_mappings.py @@ -8,7 +8,7 @@ ############################################################################## import tornado.web -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF from opnfv_testapi.resources import handlers from opnfv_testapi.resources import pod_handlers from opnfv_testapi.resources import project_handlers @@ -48,6 +48,7 @@ mappings = [ # Push results with mandatory request payload parameters # (project, case, and pod) (r"/api/v1/results", result_handlers.ResultsCLHandler), + (r'/api/v1/results/upload', result_handlers.ResultsUploadHandler), (r"/api/v1/results/([^/]+)", result_handlers.ResultsGURHandler), # scenarios @@ -57,11 +58,12 @@ mappings = [ # static path (r'/(.*\.(css|png|gif|js|html|json|map|woff2|woff|ttf))', tornado.web.StaticFileHandler, - {'path': config.Config().static_path}), + {'path': CONF.static_path}), (r'/', root.RootHandler), (r'/api/v1/auth/signin', sign.SigninHandler), (r'/api/v1/auth/signin_return', sign.SigninReturnHandler), (r'/api/v1/auth/signout', sign.SignoutHandler), (r'/api/v1/profile', user.ProfileHandler), + ] diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py b/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py index 446b9442a..cc8743ca8 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/common/test_config.py @@ -1,16 +1,15 @@ -import os +import argparse -from opnfv_testapi.common import config - -def test_config_success(): - config_file = os.path.join(os.path.dirname(__file__), - '../../../../etc/config.ini') - config.Config.CONFIG = config_file - conf = config.Config() - assert conf.mongo_url == 'mongodb://127.0.0.1:27017/' - assert conf.mongo_dbname == 'test_results_collection' - assert conf.api_port == 8000 - assert conf.api_debug is True - assert conf.api_authenticate is False - assert conf.swagger_base_url == 'http://localhost:8000' +def test_config_normal(mocker, config_normal): + mocker.patch( + 'argparse.ArgumentParser.parse_known_args', + return_value=(argparse.Namespace(config_file=config_normal), None)) + from opnfv_testapi.common import config + CONF = config.Config() + assert CONF.mongo_url == 'mongodb://127.0.0.1:27017/' + assert CONF.mongo_dbname == 'test_results_collection' + assert CONF.api_port == 8000 + assert CONF.api_debug is True + assert CONF.api_authenticate is False + assert CONF.swagger_base_url == 'http://localhost:8000' diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py b/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py new file mode 100644 index 000000000..feff1daaa --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/tests/unit/conftest.py @@ -0,0 +1,8 @@ +from os import path + +import pytest + + +@pytest.fixture +def config_normal(): + return path.join(path.dirname(__file__), 'common/normal.ini') diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py index b30c3258b..b8f696caf 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py @@ -10,6 +10,20 @@ import functools import httplib +def upload(excepted_status, excepted_response): + def _upload(create_request): + @functools.wraps(create_request) + def wrap(self): + request = create_request(self) + status, body = self.upload(request) + if excepted_status == httplib.OK: + getattr(self, excepted_response)(body) + else: + self.assertIn(excepted_response, body) + return wrap + return _upload + + def create(excepted_status, excepted_response): def _create(create_request): @functools.wraps(create_request) 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 adaf6f7c3..0ca83df62 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/fake_pymongo.py @@ -6,9 +6,10 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from operator import itemgetter + from bson.objectid import ObjectId from concurrent.futures import ThreadPoolExecutor -from operator import itemgetter def thread_execute(method, *args, **kwargs): @@ -119,10 +120,14 @@ class MemDb(object): @staticmethod def _compare_date(spec, value): + gte = True + lt = False for k, v in spec.iteritems(): - if k == '$gte' and value >= v: - return True - return False + if k == '$gte' and value < v: + gte = False + elif k == '$lt' and value < v: + lt = True + return gte and lt def _in(self, content, *args): if self.name == 'scenarios': @@ -185,9 +190,8 @@ class MemDb(object): elif k == 'trust_indicator.current': if content.get('trust_indicator').get('current') != v: return False - elif content.get(k, None) != v: + elif not isinstance(v, dict) and content.get(k, None) != v: return False - return True def _find(self, *args): diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py index 6e4d454de..dcec4e958 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py @@ -12,13 +12,9 @@ from os import path import mock from tornado import testing -from opnfv_testapi.common import config from opnfv_testapi.resources import models from opnfv_testapi.tests.unit import fake_pymongo -config.Config.CONFIG = path.join(path.dirname(__file__), - '../../../../etc/config.ini') - class TestBase(testing.AsyncHTTPTestCase): headers = {'Content-Type': 'application/json; charset=UTF-8'} @@ -37,20 +33,21 @@ class TestBase(testing.AsyncHTTPTestCase): def tearDown(self): self.db_patcher.stop() + self.config_patcher.stop() def _patch_server(self): - from opnfv_testapi.cmd import server - server.parse_config([ - '--config-file', - path.join(path.dirname(__file__), path.pardir, 'common/normal.ini') - ]) - self.db_patcher = mock.patch('opnfv_testapi.cmd.server.get_db', - self._fake_pymongo) + import argparse + config = path.join(path.dirname(__file__), '../common/normal.ini') + self.config_patcher = mock.patch( + 'argparse.ArgumentParser.parse_known_args', + return_value=(argparse.Namespace(config_file=config), None)) + self.db_patcher = mock.patch('opnfv_testapi.db.api.DB', + fake_pymongo) + self.config_patcher.start() self.db_patcher.start() - @staticmethod - def _fake_pymongo(): - return fake_pymongo + def set_config_file(self): + self.config_file = 'normal.ini' def get_app(self): from opnfv_testapi.cmd import server diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py index c8463cb02..1e83ed308 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py @@ -10,6 +10,7 @@ import copy import httplib import unittest from datetime import datetime, timedelta +import json from opnfv_testapi.common import message from opnfv_testapi.resources import pod_models @@ -60,9 +61,9 @@ class TestResultBase(base.TestBase): self.scenario = 'odl-l2' self.criteria = 'passed' self.trust_indicator = result_models.TI(0.7) - self.start_date = "2016-05-23 07:16:09.477097" - self.stop_date = "2016-05-23 07:16:19.477097" - self.update_date = "2016-05-24 07:16:19.477097" + self.start_date = str(datetime.now()) + self.stop_date = str(datetime.now() + timedelta(minutes=1)) + self.update_date = str(datetime.now() + timedelta(days=1)) self.update_step = -0.05 super(TestResultBase, self).setUp() self.details = Details(timestart='0', duration='9s', status='OK') @@ -131,6 +132,22 @@ class TestResultBase(base.TestBase): _, res = self.create_d() return res.href.split('/')[-1] + def upload(self, req): + if req and not isinstance(req, str) and hasattr(req, 'format'): + req = req.format() + res = self.fetch(self.basePath + '/upload', + method='POST', + body=json.dumps(req), + headers=self.headers) + + return self._get_return(res, self.create_res) + + +class TestResultUpload(TestResultBase): + @executor.upload(httplib.BAD_REQUEST, message.key_error('file')) + def test_filenotfind(self): + return None + class TestResultCreate(TestResultBase): @executor.create(httplib.BAD_REQUEST, message.no_body()) @@ -208,9 +225,9 @@ class TestResultCreate(TestResultBase): class TestResultGet(TestResultBase): def setUp(self): super(TestResultGet, self).setUp() + self.req_10d_before = self._create_changed_date(days=-10) self.req_d_id = self._create_d() self.req_10d_later = self._create_changed_date(days=10) - self.req_10d_before = self._create_changed_date(days=-10) @executor.get(httplib.OK, 'assert_res') def test_getOne(self): @@ -256,9 +273,9 @@ class TestResultGet(TestResultBase): def test_queryPeriodNotInt(self): return self._set_query('period=a') - @executor.query(httplib.OK, '_query_last_one', 1) + @executor.query(httplib.OK, '_query_period_one', 1) def test_queryPeriodSuccess(self): - return self._set_query('period=1') + return self._set_query('period=5') @executor.query(httplib.BAD_REQUEST, message.must_int('last')) def test_queryLastNotInt(self): @@ -268,7 +285,17 @@ class TestResultGet(TestResultBase): def test_queryLast(self): return self._set_query('last=1') - @executor.query(httplib.OK, '_query_last_one', 1) + @executor.query(httplib.OK, '_query_success', 4) + def test_queryPublic(self): + self._create_public_data() + return self._set_query('') + + @executor.query(httplib.OK, '_query_success', 1) + def test_queryPrivate(self): + self._create_private_data() + return self._set_query('public=false') + + @executor.query(httplib.OK, '_query_period_one', 1) def test_combination(self): return self._set_query('pod', 'project', @@ -279,7 +306,7 @@ class TestResultGet(TestResultBase): 'scenario', 'trust_indicator', 'criteria', - 'period=1') + 'period=5') @executor.query(httplib.OK, '_query_success', 0) def test_notFound(self): @@ -294,6 +321,14 @@ class TestResultGet(TestResultBase): 'criteria', 'period=1') + @executor.query(httplib.OK, '_query_success', 1) + def test_filterErrorStartdate(self): + self._create_error_start_date(None) + self._create_error_start_date('None') + self._create_error_start_date('null') + self._create_error_start_date('') + return self._set_query('period=5') + def _query_success(self, body, number): self.assertEqual(number, len(body.results)) @@ -301,6 +336,16 @@ class TestResultGet(TestResultBase): self.assertEqual(number, len(body.results)) self.assert_res(body.results[0], self.req_10d_later) + def _query_period_one(self, body, number): + self.assertEqual(number, len(body.results)) + self.assert_res(body.results[0], self.req_d) + + def _create_error_start_date(self, start_date): + req = copy.deepcopy(self.req_d) + req.start_date = start_date + self.create(req) + return req + def _create_changed_date(self, **kwargs): req = copy.deepcopy(self.req_d) req.start_date = datetime.now() + timedelta(**kwargs) @@ -309,16 +354,29 @@ class TestResultGet(TestResultBase): self.create(req) return req + def _create_public_data(self, **kwargs): + req = copy.deepcopy(self.req_d) + req.public = 'true' + self.create(req) + return req + + def _create_private_data(self, **kwargs): + req = copy.deepcopy(self.req_d) + req.public = 'false' + self.create(req) + return req + def _set_query(self, *args): def get_value(arg): return self.__getattribute__(arg) \ if arg != 'trust_indicator' else self.trust_indicator.current uri = '' for arg in args: - if '=' in arg: - uri += arg + '&' - else: - uri += '{}={}&'.format(arg, get_value(arg)) + if arg: + if '=' in arg: + uri += arg + '&' + else: + uri += '{}={}&'.format(arg, get_value(arg)) return uri[0: -1] diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py index b4ba88742..940e256c6 100644 --- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py +++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py @@ -10,7 +10,6 @@ from tornado import web from opnfv_testapi.common import message from opnfv_testapi.resources import project_models -from opnfv_testapi.router import url_mappings from opnfv_testapi.tests.unit import executor from opnfv_testapi.tests.unit import fake_pymongo from opnfv_testapi.tests.unit.resources import test_base as base @@ -18,6 +17,7 @@ from opnfv_testapi.tests.unit.resources import test_base as base class TestToken(base.TestBase): def get_app(self): + from opnfv_testapi.router import url_mappings return web.Application( url_mappings.mappings, db=fake_pymongo, diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/constants.py b/utils/test/testapi/opnfv_testapi/ui/auth/constants.py index 43f69d7f5..44ccb46d7 100644 --- a/utils/test/testapi/opnfv_testapi/ui/auth/constants.py +++ b/utils/test/testapi/opnfv_testapi/ui/auth/constants.py @@ -1,4 +1,6 @@ OPENID = 'openid' +ROLE = 'role' +DEFAULT_ROLE = 'user' # OpenID parameters OPENID_MODE = 'openid.mode' diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py index 6a9d94eb2..462395225 100644 --- a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py +++ b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py @@ -1,11 +1,12 @@ from six.moves.urllib import parse +from tornado import gen +from tornado import web -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF +from opnfv_testapi.db import api as dbapi from opnfv_testapi.ui.auth import base from opnfv_testapi.ui.auth import constants as const -CONF = config.Config() - class SigninHandler(base.BaseHandler): def get(self): @@ -31,20 +32,30 @@ class SigninHandler(base.BaseHandler): class SigninReturnHandler(base.BaseHandler): + @web.asynchronous + @gen.coroutine def get(self): if self.get_query_argument(const.OPENID_MODE) == 'cancel': self._auth_failure('Authentication canceled.') openid = self.get_query_argument(const.OPENID_CLAIMED_ID) - user_info = { + role = const.DEFAULT_ROLE + new_user_info = { 'openid': openid, 'email': self.get_query_argument(const.OPENID_NS_SREG_EMAIL), - 'fullname': self.get_query_argument(const.OPENID_NS_SREG_FULLNAME) + 'fullname': self.get_query_argument(const.OPENID_NS_SREG_FULLNAME), + const.ROLE: role } + user = yield dbapi.db_find_one(self.table, {'openid': openid}) + if not user: + dbapi.db_save(self.table, new_user_info) + else: + role = user.get(const.ROLE) - self.db_save(self.table, user_info) - if not self.get_secure_cookie('openid'): - self.set_secure_cookie('openid', openid) + self.clear_cookie(const.OPENID) + self.clear_cookie(const.ROLE) + self.set_secure_cookie(const.OPENID, openid) + self.set_secure_cookie(const.ROLE, role) self.redirect(url=CONF.ui_url) def _auth_failure(self, message): @@ -57,9 +68,8 @@ class SigninReturnHandler(base.BaseHandler): class SignoutHandler(base.BaseHandler): def get(self): """Handle signout request.""" - openid = self.get_secure_cookie(const.OPENID) - if openid: - self.clear_cookie(const.OPENID) + self.clear_cookie(const.OPENID) + self.clear_cookie(const.ROLE) params = {'openid_logout': CONF.osid_openid_logout_endpoint} url = parse.urljoin(CONF.ui_url, '/#/logout?' + parse.urlencode(params)) diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/user.py b/utils/test/testapi/opnfv_testapi/ui/auth/user.py index 140bca51c..955cdeead 100644 --- a/utils/test/testapi/opnfv_testapi/ui/auth/user.py +++ b/utils/test/testapi/opnfv_testapi/ui/auth/user.py @@ -2,6 +2,7 @@ from tornado import gen from tornado import web from opnfv_testapi.common import raises +from opnfv_testapi.db import api as dbapi from opnfv_testapi.ui.auth import base @@ -12,12 +13,12 @@ class ProfileHandler(base.BaseHandler): openid = self.get_secure_cookie('openid') if openid: try: - user = yield self.db_find_one({'openid': openid}) + user = yield dbapi.db_find_one(self.table, {'openid': openid}) self.finish_request({ "openid": user.get('openid'), "email": user.get('email'), "fullname": user.get('fullname'), - "is_admin": False + "role": user.get('role', 'user') }) except Exception: pass diff --git a/utils/test/testapi/opnfv_testapi/ui/root.py b/utils/test/testapi/opnfv_testapi/ui/root.py index bba7a8632..5b2c922d7 100644 --- a/utils/test/testapi/opnfv_testapi/ui/root.py +++ b/utils/test/testapi/opnfv_testapi/ui/root.py @@ -1,10 +1,10 @@ from opnfv_testapi.resources.handlers import GenericApiHandler -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF class RootHandler(GenericApiHandler): def get_template_path(self): - return config.Config().static_path + return CONF.static_path def get(self): self.render('testapi-ui/index.html') diff --git a/utils/test/testapi/requirements.txt b/utils/test/testapi/requirements.txt index d2a45dcd0..4b6f75c10 100644 --- a/utils/test/testapi/requirements.txt +++ b/utils/test/testapi/requirements.txt @@ -2,9 +2,9 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr==2.0.0 -setuptools>=16.0 -tornado>=3.1,<=4.3 +pbr>=2.0.0,!=2.1.0 # Apache-2.0 +setuptools>=16.0,!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2 # PSF/ZPL +tornado>=3.1,<=4.3 # Apache-2.0 epydoc>=0.3.1 -six>=1.9.0 -motor +six>=1.9.0 # MIT +motor # Apache-2.0 diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh deleted file mode 100755 index 1e05dd6ba..000000000 --- a/utils/test/testapi/run_test.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -o errexit - -# Get script directory -SCRIPTDIR=`dirname $0` - -echo "Running unit tests..." - -# Creating virtual environment -if [ ! -z $VIRTUAL_ENV ]; then - venv=$VIRTUAL_ENV -else - venv=$SCRIPTDIR/.venv - virtualenv $venv -fi -source $venv/bin/activate - -# Install requirements -pip install -r $SCRIPTDIR/requirements.txt -pip install -r $SCRIPTDIR/test-requirements.txt - -find . -type f -name "*.pyc" -delete - -nosetests --with-xunit \ - --with-coverage \ - --cover-erase \ - --cover-package=$SCRIPTDIR/opnfv_testapi/cmd \ - --cover-package=$SCRIPTDIR/opnfv_testapi/common \ - --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 index 3bead7987..233f4652b 100644 --- a/utils/test/testapi/test-requirements.txt +++ b/utils/test/testapi/test-requirements.txt @@ -2,9 +2,9 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -coverage -mock>=2.0 -nose>=1.3.1 -pytest -pytest-cov -pytest-mock +coverage>=4.0,!=4.4 # Apache-2.0 +mock>=2.0 # BSD +nose # LGPL +pytest # MIT +pytest-cov # MIT +pytest-mock # MIT |