Update Automation Job Repo to releng-testresults 73/47073/1
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Fri, 10 Nov 2017 23:35:30 +0000 (15:35 -0800)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Fri, 10 Nov 2017 23:40:12 +0000 (15:40 -0800)
Switches the jjb/releng/automate jobs to use the releng-testresults
repository now that files under utils/test have been migrated.

Assumes shell and python scripts required for the job are now located
in the releng-testresults repo under ./ci/

Change-Id: I1f036d9d8abd988477e18b2f2efd8f80d550a61c
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
jjb/releng/automate.yml
jjb/releng/docker-deploy.sh [deleted file]
jjb/releng/docker-update.sh [deleted file]
jjb/releng/htmlize/doc-build.sh [deleted file]
jjb/releng/htmlize/htmlize.py [deleted file]
jjb/releng/htmlize/push-doc-artifact.sh [deleted file]
jjb/releng/testapi-backup-mongodb.sh [deleted file]

index de7fcd6..afeb358 100644 (file)
@@ -19,7 +19,7 @@
       - '{module}-automate-{phase}-{stream}'
       - '{module}-verify-{stream}'
 
-    project: 'releng'
+    project: 'releng-testresults'
 
 - job:
     name: 'testapi-mongodb-backup'
           default: 'testresults'
           description: 'Slave label on Jenkins'
       - project-parameter:
-          project: 'releng'
+          project: 'releng-testresults'
           branch: 'master'
       - string:
           name: GIT_BASE
-          default: https://gerrit.opnfv.org/gerrit/releng
+          default: https://gerrit.opnfv.org/gerrit/releng-testresults
           description: 'Git URL to use on this Jenkins Slave'
 
     scm:
                   branch-pattern: '**/{branch}'
               file-paths:
                 - compare-type: 'ANT'
-                  pattern: 'utils/test/{module}/**'
+                  pattern: '{module}/**'
 
     builders:
       - shell: |
-          cd ./utils/test/{module}/
+          cd {module}/
           tox
           if [ -e *.xml ];then
               cp *.xml $WORKSPACE
                   branch-pattern: '**/{branch}'
               file-paths:
                 - compare-type: 'ANT'
-                  pattern: 'utils/test/{module}/**'
+                  pattern: '{module}/**'
 
     builders:
       - description-setter:
 - builder:
     name: 'docker-update'
     builders:
-      - shell:
-          !include-raw: ./docker-update.sh
+      - shell: |
+          bash ./ci/docker-update.sh
 
 - builder:
     name: 'testapi-automate-generate-doc-macro'
     name: 'testapi-doc-build'
     builders:
       - shell: |
-          bash ./jjb/releng/htmlize/doc-build.sh
+          bash ./ci/htmlize/doc-build.sh
 
 - builder:
     name: 'upload-doc-artifact'
     builders:
       - shell: |
-          bash ./jjb/releng/htmlize/push-doc-artifact.sh
+           bash ./ci/htmlize/push-doc-artifacts.sh
 
 - builder:
     name: 'reporting-automate-generate-doc-macro'
     name: 'testapi-automate-docker-deploy-macro'
     builders:
       - shell: |
-          sudo bash ./jjb/releng/docker-deploy.sh "sudo docker run -dti --name testapi -p 8082:8000
+          sudo bash ./ci/docker-deploy.sh "sudo docker run -dti --name testapi -p 8082:8000
           -e mongodb_url=mongodb://172.17.0.1:27017
           -e base_url=http://testresults.opnfv.org/test opnfv/testapi" \
           "http://testresults.opnfv.org/test/" "testapi"
     name: 'reporting-automate-docker-deploy-macro'
     builders:
       - shell: |
-          sudo bash ./jjb/releng/docker-deploy.sh "sudo docker run -itd --name reporting -p 8084:8000 opnfv/reporting" \
+          sudo bash ./ci/docker-deploy.sh \
+          "sudo docker run -itd --name reporting -p 8084:8000 opnfv/reporting" \
           "http://testresults.opnfv.org/reporting/index.html" "reporting"
 
 - builder:
     name: mongodb-backup
     builders:
-      - shell: |
-          bash ./jjb/releng/testapi-backup-mongodb.sh
+      - shell:
+          bash ./ci/testapi-backup-mongodb.sh
 
 ################################
 # job publishers
diff --git a/jjb/releng/docker-deploy.sh b/jjb/releng/docker-deploy.sh
deleted file mode 100644 (file)
index 1e83577..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-#  Licensed to the Apache Software Foundation (ASF) under one   *
-#  or more contributor license agreements.  See the NOTICE file *
-#  distributed with this work for additional information        *
-#  regarding copyright ownership.  The ASF licenses this file   *
-#  to you under the Apache License, Version 2.0 (the            *
-#  "License"); you may not use this file except in compliance   *
-#  with the License.  You may obtain a copy of the License at   *
-#                                                               *
-#    http://www.apache.org/licenses/LICENSE-2.0                 *
-#                                                               *
-#  Unless required by applicable law or agreed to in writing,   *
-#  software distributed under the License is distributed on an  *
-#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
-#  KIND, either express or implied.  See the License for the    *
-#  specific language governing permissions and limitations      *
-#  under the License.                                           *
-
-
-command=$1
-url=$2
-module=$3
-
-REPO="opnfv"
-latest_image=$REPO/$module:latest
-old_image=$REPO/$module:old
-latest_container_name=$module
-old_container_name=$module"_old"
-latest_container_id=
-old_container_id=
-new_start_container=
-
-function DEBUG() {
-  echo `date "+%Y-%m-%d %H:%M:%S.%N"` ": $1"
-}
-
-function check_connectivity() {
-    # check update status via test the connectivity of provide url
-    sleep 5
-    cmd=`curl -s --head  --request GET ${url} | grep '200 OK' > /dev/null`
-    rc=$?
-    DEBUG $rc
-    if [[ $rc == 0 ]]; then
-        return 0
-    else
-        return 1
-    fi
-}
-
-
-function pull_latest_image() {
-    DEBUG "pull latest image $latest_image"
-    docker pull $latest_image
-}
-
-function get_latest_running_container() {
-    latest_container_id=`docker ps -q --filter name=^/$latest_container_name$`
-}
-
-function get_old_running_container() {
-    old_container_id=`docker ps -q --filter name=^/$old_container_name$`
-}
-
-function delete_old_image() {
-    DEBUG "delete old image: $old_image"
-    docker rmi -f $old_image
-}
-
-function delete_old_container() {
-    DEBUG "delete old container: $old_container_name"
-    docker ps -a -q --filter name=^/$old_container_name$ | xargs docker rm -f &>/dev/null
-}
-
-function delete_latest_container() {
-    DEBUG "delete latest container: $module"
-    docker ps -a -q --filter name=^/$latest_container_name$ | xargs docker rm -f &>/dev/null
-}
-
-function delete_latest_image() {
-    DEBUG "delete latest image: $REPO/$module:latest"
-    docker rmi -f $latest_image
-}
-
-function change_image_tag_2_old() {
-    DEBUG "change image tag 2 old"
-    docker tag $latest_image $old_image
-    docker rmi -f $latest_image
-}
-
-function mark_latest_container_2_old() {
-    DEBUG "mark latest container to be old"
-    docker rename "$latest_container_name" "$old_container_name"
-}
-
-function stop_old_container() {
-    DEBUG "stop old container"
-    docker stop "$old_container_name"
-}
-
-function run_latest_image() {
-    new_start_container=`$command`
-    DEBUG "run latest image: $new_start_container"
-}
-
-get_latest_running_container
-get_old_running_container
-
-if [[ ! -z $latest_container_id ]]; then
-    DEBUG "latest container is running: $latest_container_id"
-    delete_old_container
-    delete_old_image
-    change_image_tag_2_old
-    mark_latest_container_2_old
-    pull_latest_image
-    stop_old_container
-    run_latest_image
-
-elif [[ ! -z $old_container_id ]]; then
-    DEBUG "old container is running: $old_container_id"
-    delete_latest_container
-    delete_latest_image
-    pull_latest_image
-    stop_old_container
-    run_latest_image
-else
-    DEBUG "no container is running"
-    delete_old_container
-    delete_old_image
-    delete_latest_container
-    delete_latest_image
-    pull_latest_image
-    run_latest_image
-fi
-
-if check_connectivity; then
-    DEBUG "CONGRATS: $module update successfully"
-else
-    DEBUG "ATTENTION: $module update failed"
-    id=`docker ps -a -q --filter name=^/$old_container_name$`
-    if [[ ! -z $id ]]; then
-        DEBUG "start old container instead"
-        docker stop $new_start_container
-        docker start $id
-    fi
-    if ! check_connectivity; then
-        DEBUG "BIG ISSUE: no container is running normally"
-    fi
-    exit 1
-fi
-
-docker images
-docker ps -a
diff --git a/jjb/releng/docker-update.sh b/jjb/releng/docker-update.sh
deleted file mode 100644 (file)
index 559ac83..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-#  Licensed to the Apache Software Foundation (ASF) under one   *
-#  or more contributor license agreements.  See the NOTICE file *
-#  distributed with this work for additional information        *
-#  regarding copyright ownership.  The ASF licenses this file   *
-#  to you under the Apache License, Version 2.0 (the            *
-#  "License"); you may not use this file except in compliance   *
-#  with the License.  You may obtain a copy of the License at   *
-#                                                               *
-#    http://www.apache.org/licenses/LICENSE-2.0                 *
-#                                                               *
-#  Unless required by applicable law or agreed to in writing,   *
-#  software distributed under the License is distributed on an  *
-#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
-#  KIND, either express or implied.  See the License for the    *
-#  specific language governing permissions and limitations      *
-#  under the License.                                           *
-
-set -o errexit
-set -o nounset
-
-cd $WORKSPACE/utils/test/$MODULE_NAME/docker/
-
-# Remove previous containers
-docker ps -a | grep "opnfv/$MODULE_NAME" | awk '{ print $1 }' | xargs -r docker rm -f
-
-# Remove previous images
-docker images | grep "opnfv/$MODULE_NAME" | awk '{ print $3 }' | xargs -r docker rmi -f
-
-# Start build
-docker build --no-cache -t opnfv/$MODULE_NAME:$DOCKER_TAG .
-
-# Push Image
-docker push opnfv/$MODULE_NAME:$DOCKER_TAG
diff --git a/jjb/releng/htmlize/doc-build.sh b/jjb/releng/htmlize/doc-build.sh
deleted file mode 100644 (file)
index b89baa8..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-#  Licensed to the Apache Software Foundation (ASF) under one   *
-#  or more contributor license agreements.  See the NOTICE file *
-#  distributed with this work for additional information        *
-#  regarding copyright ownership.  The ASF licenses this file   *
-#  to you under the Apache License, Version 2.0 (the            *
-#  "License"); you may not use this file except in compliance   *
-#  with the License.  You may obtain a copy of the License at   *
-#                                                               *
-#    http://www.apache.org/licenses/LICENSE-2.0                 *
-#                                                               *
-#  Unless required by applicable law or agreed to in writing,   *
-#  software distributed under the License is distributed on an  *
-#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
-#  KIND, either express or implied.  See the License for the    *
-#  specific language governing permissions and limitations      *
-#  under the License.                                           *
-
-set -o errexit
-
-# Create virtual environment
-virtualenv $WORKSPACE/testapi_venv
-source $WORKSPACE/testapi_venv/bin/activate
-
-# Swgger Codegen Tool
-url="http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar"
-
-# Check for jar file locally and in the repo
-if [ ! -f swagger-codegen-cli.jar ];
-then
-    wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar -O swagger-codegen-cli.jar
-fi
-
-# Install Pre-requistics
-pip install requests
-
-python ./jjb/releng/htmlize/htmlize.py -o ${WORKSPACE}/
diff --git a/jjb/releng/htmlize/htmlize.py b/jjb/releng/htmlize/htmlize.py
deleted file mode 100644 (file)
index da6a6cf..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env python
-
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-
-import argparse
-import requests
-import json
-import os
-
-
-def main(args):
-
-    # Merging two specs
-    api_response = requests.get(args.api_declaration_url)
-    api_response = json.loads(api_response.content)
-    resource_response = requests.get(args.resource_listing_url)
-    resource_response = json.loads(resource_response.content)
-    resource_response['models'] = api_response['models']
-    resource_response['apis'] = api_response['apis']
-
-    # Storing the swagger specs
-    with open('specs.json', 'w') as outfile:
-        json.dump(resource_response, outfile)
-
-    # Generating html page
-    cmd = 'java -jar swagger-codegen-cli.jar generate \
-        -i specs.json -l html2 -o %s' % (args.output_directory)
-    if os.system(cmd) == 0:
-        exit(0)
-    else:
-        exit(1)
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser(description='Create \
-                                      Swagger Spec documentation')
-    parser.add_argument('-ru', '--resource-listing-url',
-                        type=str,
-                        required=False,
-                        default=('http://testresults.opnfv.org'
-                                 '/test/swagger/resources.json'),
-                        help='Resource Listing Spec File')
-    parser.add_argument('-au', '--api-declaration-url',
-                        type=str,
-                        required=False,
-                        default=('http://testresults.opnfv.org'
-                                 '/test/swagger/APIs'),
-                        help='API Declaration Spec File')
-    parser.add_argument('-o', '--output-directory',
-                        required=True,
-                        default='./',
-                        help='Output Directory where the \
-                                file should be stored')
-    main(parser.parse_args())
diff --git a/jjb/releng/htmlize/push-doc-artifact.sh b/jjb/releng/htmlize/push-doc-artifact.sh
deleted file mode 100644 (file)
index 4cf1988..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-set -e
-set -o pipefail
-
-export PATH=$PATH:/usr/local/bin/
-
-project=$PROJECT
-workspace=$WORKSPACE
-artifact_dir="$project/docs"
-
-set +e
-gsutil&>/dev/null
-if [ $? != 0 ]; then
-    echo "Not possible to push results to artifact: gsutil not installed"
-    exit 1
-else
-    gsutil ls gs://artifacts.opnfv.org/"$project"/ &>/dev/null
-    if [ $? != 0 ]; then
-        echo "Not possible to push results to artifact: gsutil not installed."
-        exit 1
-    else
-        echo "Uploading document to artifact $artifact_dir"
-        gsutil cp "$workspace"/index.html gs://artifacts.opnfv.org/"$artifact_dir"/testapi.html >/dev/null 2>&1
-        echo "Document can be found at http://artifacts.opnfv.org/releng/docs/testapi.html"
-    fi
-fi
diff --git a/jjb/releng/testapi-backup-mongodb.sh b/jjb/releng/testapi-backup-mongodb.sh
deleted file mode 100644 (file)
index 795e479..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-set -e
-
-# Run MongoDB backup
-python $WORKSPACE/utils/test/testapi/update/templates/backup_mongodb.py -o $WORKSPACE/
-
-# Compressing the dump
-now=$(date +"%m_%d_%Y_%H_%M_%S")
-echo $now
-
-file_name="testapi_mongodb_"$now".tar.gz"
-echo $file_name
-
-tar cvfz "$file_name" test_results_collection*
-
-rm -rf test_results_collection*
-
-artifact_dir="testapibackup"
-workspace="$WORKSPACE"
-
-set +e
-/usr/local/bin/gsutil &>/dev/null
-if [ $? != 0 ]; then
-    echo "Not possible to push results to artifact: gsutil not installed"
-    exit 1
-else
-    echo "Uploading mongodump to artifact $artifact_dir"
-    /usr/local/bin/gsutil cp -r "$workspace"/"$file_name" gs://artifacts.opnfv.org/"$artifact_dir"/
-    echo "MongoDump can be found at http://artifacts.opnfv.org/$artifact_dir.html"
-fi