Add common functions to openstack deploy script 96/67796/6
authorJamo Luhrsen <jluhrsen@redhat.com>
Wed, 31 Jan 2018 01:46:10 +0000 (17:46 -0800)
committerSam Hague <shague@redhat.com>
Fri, 2 Feb 2018 19:34:39 +0000 (14:34 -0500)
Change-Id: I03816aeaa41b0c8376f431f70da94e9b9260bd21
Signed-off-by: Sam Hague <shague@redhat.com>
jjb/integration/common-functions.sh
jjb/integration/copy-common-functions.sh [new file with mode: 0644]
jjb/integration/integration-configure-clustering.sh
jjb/integration/integration-deploy-controller-run-test.sh
jjb/integration/integration-macros.yaml
jjb/integration/integration-templates.yaml
jjb/integration/integration4-templates.yaml

index 7e3b3b648eae7f491bfc04e04583ebb1d00b90a6..9955847e7d0b855037d2c1b4315ed13dc7d146bd 100644 (file)
@@ -1,5 +1,9 @@
 #!/bin/bash
 
+echo "common-functions.sh is being sourced"
+
+BUNDLEFOLDER=$1
+
 # Basic controller configuration settings
 export MAVENCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.url.mvn.cfg
 export FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
@@ -13,12 +17,31 @@ export AKKACONF=/tmp/${BUNDLEFOLDER}/configuration/initial/akka.conf
 export MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
 export MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
 
+function print_common_env() {
+    cat << EOF
+common-functions environment:
+MAVENCONF: ${MAVENCONF}
+FEATURESCONF: ${FEATURESCONF}
+CUSTOMPROP: ${CUSTOMPROP}
+LOGCONF: ${LOGCONF}
+MEMCONF: ${MEMCONF}
+CONTROLLERMEM: ${CONTROLLERMEM}
+AKKACONF: ${AKKACONF}
+MODULESCONF: ${MODULESCONF}
+MODULESHARDSCONF: ${MODULESHARDSCONF}
+
+EOF
+}
+print_common_env
+
 # Setup JAVA_HOME and MAX_MEM Value in ODL startup config file
 function set_java_vars() {
+    local JAVA_HOME=$1
 
     echo "Configure java home and max memory..."
-    sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' ${MEMCONF}
-    sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' ${MEMCONF}
+    sed -ie 's%^# export JAVA_HOME%export JAVA_HOME=${JAVA_HOME:-'"${JAVA_HOME}"'}%g' ${MEMCONF}
+    sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM='"${CONTROLLERMEM}"'/g' ${MEMCONF}
+    echo "cat ${MEMCONF}"
     cat ${MEMCONF}
 
     echo "Set Java version"
@@ -30,6 +53,6 @@ function set_java_vars() {
     echo "Set JAVA_HOME"
     export JAVA_HOME="${JAVA_HOME}"
     # shellcheck disable=SC2037
-    JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
-    echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
+    JAVA_RESOLVED=$(readlink -e "${JAVA_HOME}/bin/java")
+    echo "Java binary pointed at by JAVA_HOME: ${JAVA_RESOLVED}"
 } # set_java_vars()
diff --git a/jjb/integration/copy-common-functions.sh b/jjb/integration/copy-common-functions.sh
new file mode 100644 (file)
index 0000000..4572ee1
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Copy the whole script to /tmp/common-functions.sh and to remote nodes but
+# only if this script itself is executing and not sourced. jenkins prepends this
+# script to the common-functions.sh script when adding it to the robot minion.
+# jenkins with then execute the script. The if check below checks that the
+# script is executing rather than being sourced. When executed the condition
+# is true and copies the script. In the false path this copy below is skipped
+# and the common-function.sh ends up sourced.
+if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
+    echo "Copying common-functions.sh to /tmp"
+    cp "${0}" /tmp/common-functions.sh
+
+    [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
+    NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
+    for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
+        for j in `seq 1 ${NUM_ODLS_PER_SITE}`; do
+            odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
+            echo "Copying common-functions.sh to ${!odl_ip}:/tmp"
+            scp /tmp/common-functions.sh ${!odl_ip}:/tmp
+        done
+    done
+    # TODO: add copy to openstack systems when needed
+    exit 0
+fi
index 5b1db13ec908f13a2ccd58676d2918d611fe6c38..00745aa38c133f393fd02a0a0ab9002f19482a0c 100644 (file)
@@ -4,6 +4,7 @@
 # script.
 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
 source ${ROBOT_VENV}/bin/activate
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 echo "#################################################"
 echo "##         Configure Cluster and Start         ##"
@@ -55,6 +56,8 @@ fi
 
 # Create the configuration script to be run on controllers.
 cat > ${WORKSPACE}/configuration-script.sh <<EOF
+set -x
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 echo "Changing to /tmp"
 cd /tmp
@@ -105,7 +108,7 @@ if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
   cat ${CUSTOMPROP}
 fi
 
-set_java_vars
+set_java_vars "${JAVA_HOME}"
 
 # Copy shard file if exists
 if [ -f /tmp/custom_shard_config.txt ]; then
index c6beeed410da498e9cccb2a5dc1db1b0ee6ab7fd..06cc4542e8912620d722b3760787f613242f9de2 100644 (file)
@@ -4,7 +4,7 @@
 # script.
 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
 source ${ROBOT_VENV}/bin/activate
-
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
     echo "Configure cluster"
@@ -45,6 +45,8 @@ if [ -f "${WORKSPACE}/test/csit/scriptplans/${TESTPLAN}" ]; then
 fi
 
 cat > ${WORKSPACE}/configuration-script.sh <<EOF
+set -x
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 echo "Changing to /tmp"
 cd /tmp
@@ -96,9 +98,10 @@ if [ -n "${CONTROLLERDEBUGMAP}" ]; then
         fi
     done
 fi
+echo "cat ${LOGCONF}"
 cat ${LOGCONF}
 
-set_java_vars
+set_java_vars "${JAVA_HOME}"
 
 echo "Listing all open ports on controller system..."
 netstat -pnatu
@@ -126,6 +129,7 @@ if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
 fi
 
 EOF
+# cat > ${WORKSPACE}/configuration-script.sh <<EOF
 
 # Create the startup script to be run on controller.
 cat > ${WORKSPACE}/startup-script.sh <<EOF
@@ -138,6 +142,7 @@ echo "Starting controller..."
 /tmp/${BUNDLEFOLDER}/bin/start
 
 EOF
+# cat > ${WORKSPACE}/startup-script.sh <<EOF
 
 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
 
@@ -217,6 +222,7 @@ exit_on_log_file_message 'BindException: Address already in use'
 exit_on_log_file_message 'server is unhealthy'
 
 EOF
+# cat > ${WORKSPACE}/post-startup-script.sh <<EOF
 
 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
index 4e2ccf0de917121a68700a164963f25d0c4ba7d0..f2df2a0624c9245c9a41142985b9f81528a33e70 100644 (file)
 - builder:
     name: integration-deploy-controller-run-test
     builders:
-      - shell: !include-raw:
-          - common-functions.sh
-          - integration-deploy-controller-run-test.sh
+      - shell: !include-raw: integration-deploy-controller-run-test.sh
 
 # Macro: integration-configure-clustering
 # Operation: this macro configures the clustering
 - builder:
     name: integration-configure-clustering
     builders:
-      - shell: !include-raw:
-          - common-functions.sh
-          - integration-configure-clustering.sh
+      - shell: !include-raw: integration-configure-clustering.sh
 
 # Macro: integration-start-cluster-run-test
 # Operation: this macro starts the 3-node cluster and runs test
     builders:
       - shell: !include-raw: integration-rebase-gerrit-patch.sh
 
+# Macro: integration-install-common-functions
+# Operation: Copy the common-functions.sh script to csit nodes
+# Used by: *-csit-* job templates
+- builder:
+    name: integration-install-common-functions
+    builders:
+      - shell: !include-raw:
+          - copy-common-functions.sh
+          - common-functions.sh
+
 - builder:
     name: integration-deploy-openstack-run-test
     builders:
-      - shell: !include-raw: integration-deploy-openstack-run-test.sh
+      - shell: !include-raw:
+          - integration-deploy-openstack-run-test.sh
 
 - builder:
     name: integration-compare-distributions
index b203a38717d6f25e44c06da513ce4e7ce2355f74..da9c33863a06243b844c5c2001dd35c30dee8112 100644 (file)
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-cleanup-tmp
 
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-cleanup-tmp
 
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-cleanup-tmp
 
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-deploy-openstack-run-test
       - integration-cleanup-tmp
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-deploy-openstack-run-test
       - integration-cleanup-tmp
index 9539c82841f94e9d11f3b0f159da1fe482e8b641..fab8aa6e047ef015e5f7792a8a8c766070af0e6e 100644 (file)
@@ -69,6 +69,7 @@
       - inject:
           properties-file: 'slave_addresses.txt'
       - integration-detect-variables
+      - integration-install-common-functions
       - integration-deploy-controller-run-test
       - integration-cleanup-tmp