aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNuoHan Qiao <qiaonuohan@cn.fujitsu.com>2016-01-24 21:26:39 -0500
committerNuoHan Qiao <qiaonuohan@cn.fujitsu.com>2016-01-25 03:44:36 -0500
commit8875b3c9fffb2a32b011e45ad83baac54b46d4a3 (patch)
tree9e0efd87122b1bc7023092ea34139fea8a843851
parent385a0ae062fca5927401d0cf880b3940b9d6ac0f (diff)
Add CIAT.build_deploy
This test cases is used to build a image for porter and deploy the image to the tftp/nfs server. After the deploy is finished, porter will be rebooted. Here is a trick about how to reboot with the newly built image. Please check the documents about how to use CIAT. This document will uploaded with later patches. Change-Id: I29d5bd6042d24b21befcb3b88f04d0064591ecb5 Signed-off-by: NuoHan Qiao <qiaonuohan@cn.fujitsu.com>
-rw-r--r--jta-core/engine/tests/CIAT.build_deploy/agl_build.sh137
-rw-r--r--jta-core/engine/tests/CIAT.build_deploy/build_deploy.sh75
-rw-r--r--jta-core/jobs/CIAT.build_deploy/config.xml133
3 files changed, 345 insertions, 0 deletions
diff --git a/jta-core/engine/tests/CIAT.build_deploy/agl_build.sh b/jta-core/engine/tests/CIAT.build_deploy/agl_build.sh
new file mode 100644
index 0000000..fd112b0
--- /dev/null
+++ b/jta-core/engine/tests/CIAT.build_deploy/agl_build.sh
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+set -e
+set -x
+
+# check execution path (specified by 1st parameter)
+if test -z "$1"; then
+ echo "ERROR: execution path is not specified"
+ exit 1
+fi
+
+EXEC_PATH=`cd $1; pwd`
+
+echo > "$EXEC_PATH/agl_build.log"
+
+if test x"$PWD" != x"$EXEC_PATH"; then
+ echo "ERROR: wrong path ($PWD), need to be executed under $EXEC_PATH" > "$1/agl_build.log"
+ exit 1
+fi
+
+# get repo command
+if test -f ~/bin/repo; then
+ echo "INFO: ~/bin/repo is ready" > agl_build.log
+else
+ mkdir -p ~/bin
+ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
+fi
+
+chmod a+x ~/bin/repo
+export PATH=~/bin:$PATH
+
+
+# create shared downloads and sstate-cache directory
+mkdir -p downloads
+mkdir -p sstate-cache
+
+
+# remove old files, we want to test a fresh clone
+export XTMP="$$"
+mv repoclone repoclone$XTMP || true
+( rm -rf repoclone$XTMP & ) || true
+mkdir -p repoclone
+cd repoclone
+
+
+# check if master or branch
+if test x"" != x"$GERRIT_BRANCH"; then
+ # special for meta-renesas ...
+ if test x"agl-1.0-bsp-1.8.0" == x"$GERRIT_BRANCH" ; then
+ export REPOCLONE=master
+ else
+ export REPOCLONE="$GERRIT_BRANCH"
+ fi
+
+ repo init -q -b $REPOCLONE -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
+else
+ echo ""
+ echo "####################################################"
+ echo "ATTENTION: NO GERRIT_BRANCH, using master by default"
+ echo "####################################################"
+ echo ""
+
+ repo init -q -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
+fi
+
+# this is for testing, a copy of repoclone should be placed under /compile/agl-demo/CIAT.bak/,
+# or don't set SPEEDUP_TEST to yes
+if test x"$SPEEDUP_TEST" == x"yes"; then
+ rm -rf .repo/
+
+ cp -r /compile/agl-demo/CIAT.bak/repoclone/.repo/ ./
+ cp -r /compile/agl-demo/CIAT.bak/repoclone/meta-* ./
+ cp -r /compile/agl-demo/CIAT.bak/repoclone/poky/ ./
+fi
+
+
+# next: repo sync and dump manifest
+repo sync --force-sync --detach --no-clone-bundle
+MYPROJECT=`echo $GERRIT_PROJECT | sed -e "s#AGL/##g"`
+cd $MYPROJECT
+
+
+# we need to inject the git ref of GERRIT_PATCHSET_REVISION to the recipe
+if test x"" != x"${GERRIT_REFSPEC}" ; then
+ MYREMOTE=`git remote | head -1`
+ git fetch $MYREMOTE ${GERRIT_REFSPEC}
+ git reset --hard FETCH_HEAD
+# git status
+# git log -1
+else
+ echo "Something is wrong, we have no GERRIT_PATCHSET_REVISION. Exit."
+ exit 1
+fi
+
+cd ..
+
+repo manifest -r > ../current_default.xml
+
+
+# source the env
+export MACHINE=porter
+source meta-agl/scripts/envsetup.sh $MACHINE
+
+
+# link the shared downloads and sstate-cache
+ln -sf ../../downloads
+ln -sf ../../sstate-cache
+
+echo "" >> conf/local.conf
+echo 'IMAGE_INSTALL_append = " mc"' >> conf/local.conf
+
+# finally, build the agl-demo-platform
+bitbake agl-demo-platform || exit 1
+du -hs tmp/deploy/*
+
+
+# create the archive
+mkdir -p archive
+cp ../../current_default.xml archive/
+cp conf/local.conf archive/
+tar -C tmp/deploy -cf archive/licenses.tar licenses
+
+
+echo "We provide the repo default.xml in the file current_default.xml." > archive/README.sources
+echo "This will pull down the yocto layers used to build this snapshot." >> archive/README.sources
+echo "" >> archive/README.sources
+echo "After syncing repo with the above default.xml, simply follow" >> archive/README.sources
+echo "the steps in the README.md of meta-agl-demo" >> archive/README.sources
+echo "" >> archive/README.sources
+echo "Source can be fetched with:" >> archive/README.sources
+echo " bitbake -c fetchall agl-demo-platform" >> archive/README.sources
+echo "" >> archive/README.sources
+echo "A mirror of all sources used is also available here:" >> archive/README.sources
+echo " http://download.automotivelinux.org/AGL/mirror/" >> archive/README.sources
+echo "" >> archive/README.sources
+echo "The AGL components are hosted at:" >> archive/README.sources
+echo " https://git.automotivelinux.org/" >> archive/README.sources
diff --git a/jta-core/engine/tests/CIAT.build_deploy/build_deploy.sh b/jta-core/engine/tests/CIAT.build_deploy/build_deploy.sh
new file mode 100644
index 0000000..5a48ce2
--- /dev/null
+++ b/jta-core/engine/tests/CIAT.build_deploy/build_deploy.sh
@@ -0,0 +1,75 @@
+source $JTA_SCRIPTS_PATH/overlays.sh
+set_overlay_vars
+
+source $JTA_SCRIPTS_PATH/reports.sh
+source $JTA_SCRIPTS_PATH/functions.sh
+
+SERVER_SCP="scp -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=15"
+SERVER_SSH="ssh -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=15"
+IMAGE_PATH="$IMAGE_PATH/$PLATFORM"
+
+BUILD_SCRIPT="agl_build.sh"
+
+function build_image {
+ env
+
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SSH "$BUILD_USER"@"$BUILD_SERVERIP" "mkdir -p $BUILD_PATH"
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SCP "$TEST_HOME/$BUILD_SCRIPT" "$BUILD_USER"@"$BUILD_SERVERIP":"$BUILD_PATH"
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SSH "$BUILD_USER"@"$BUILD_SERVERIP" "chmod 700 $BUILD_PATH/$BUILD_SCRIPT"
+
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SSH "$BUILD_USER"@"$BUILD_SERVERIP" \
+ "cd $BUILD_PATH; \
+ export SPEEDUP_TEST=no; \
+ export GERRIT_PROJECT=$GERRIT_PROJECT; \
+ export GERRIT_BRANCH=$GERRIT_BRANCH; \
+ export GERRIT_REFSPEC=$GERRIT_REFSPEC; \
+ ./$BUILD_SCRIPT $BUILD_PATH"
+}
+
+function deploy_image {
+ # get image from compile server
+ mkdir -p "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}"
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SCP "$BUILD_USER"@"$BUILD_SERVERIP":"$BUILD_PATH/repoclone/$IMAGE_PATH/$UIMAGE" "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}"
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SCP "$BUILD_USER"@"$BUILD_SERVERIP":"$BUILD_PATH/repoclone/$IMAGE_PATH/$DTB" "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}"
+ sshpass -p "$BUILD_PASSWORD" $SERVER_SCP "$BUILD_USER"@"$BUILD_SERVERIP":"$BUILD_PATH/repoclone/$IMAGE_PATH/$IMAGE" "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}"
+
+ # deploy image to tftp/nfs server
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SSH root@"$BOOT_SERVERIP" "mkdir -p $BOOT_TFTP_PATH/${BUILD_ID}; echo boot_num=${BUILD_ID} > $BOOT_TFTP_PATH/$BOOT_NUM_FILE"
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SCP "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}/$UIMAGE" root@"$BOOT_SERVERIP":"$BOOT_TFTP_PATH/${BUILD_ID}"
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SCP "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}/$DTB" root@"$BOOT_SERVERIP":"$BOOT_TFTP_PATH/${BUILD_ID}"
+
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SSH root@"$BOOT_SERVERIP" "mkdir -p $BOOT_NFS_PATH/${BUILD_ID}"
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SCP "$JTA_LOGS_PATH/${JOB_NAME}/testlogs/${NODE_NAME}.${BUILD_ID}.${BUILD_NUMBER}/$IMAGE" root@"$BOOT_SERVERIP":"$BOOT_NFS_PATH/${BUILD_ID}"
+ sshpass -p "$BOOT_PASSWORD" $SERVER_SSH root@"$BOOT_SERVERIP" "cd $BOOT_NFS_PATH/${BUILD_ID}; tar xvf $IMAGE; touch new_image_flag.${BUILD_ID}"
+}
+
+function reboot_to_new_image {
+ safe_cmd "export PATH=/sbin:$PATH; shutdown -r now &"
+
+ sleep $REBOOT_WAIT
+
+ # since the system is rebooted with a new image, directories for test should be created again
+ safe_cmd "rm -rf $JTA_HOME/jta.$TESTDIR /tmp/$TESTDIR; mkdir -p $JTA_HOME/jta.$TESTDIR /tmp/jta.$TESTDIR" || abort_job "Could not create $TESTDIR and /tmp/$TESTDIR on $DEVICE"
+}
+
+function test_deploy {
+ build_image
+
+ deploy_image
+
+ reboot_to_new_image
+}
+
+function test_run {
+ # a flag is created on nfs server, and it is checked here to make sure the system is rebooted with the new image
+ report "ls /new_image_flag.${BUILD_ID}"
+}
+
+pre_test $TESTDIR
+
+deploy
+
+test_run
+#get_testlog $TESTDIR
+
+#test_processing
diff --git a/jta-core/jobs/CIAT.build_deploy/config.xml b/jta-core/jobs/CIAT.build_deploy/config.xml
new file mode 100644
index 0000000..01b0ae8
--- /dev/null
+++ b/jta-core/jobs/CIAT.build_deploy/config.xml
@@ -0,0 +1,133 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <actions/>
+ <description></description>
+ <logRotator class="hudson.tasks.LogRotator">
+ <daysToKeep>-1</daysToKeep>
+ <numToKeep>300</numToKeep>
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
+ <artifactNumToKeep>-1</artifactNumToKeep>
+ </logRotator>
+ <keepDependencies>false</keepDependencies>
+ <properties>
+ <jp.ikedam.jenkins.plugins.groovy__label__assignment.GroovyLabelAssignmentProperty plugin="groovy-label-assignment@1.0.0">
+ <groovyScript> return s = binding.getVariables().get(&quot;Device&quot;).toString()</groovyScript>
+ </jp.ikedam.jenkins.plugins.groovy__label__assignment.GroovyLabelAssignmentProperty>
+ <hudson.queueSorter.PrioritySorterJobProperty plugin="PrioritySorter@1.2">
+ <priority>100</priority>
+ </hudson.queueSorter.PrioritySorterJobProperty>
+ <hudson.model.ParametersDefinitionProperty>
+ <parameterDefinitions>
+ <com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerChoiceParameterDefinition plugin="dynamicparameter@0.2.1-SNAPSHOT">
+ <name>Device</name>
+ <description>(target)</description>
+ <__uuid>44a1b472-f3d4-4657-8fac-6c65f7b1e5cd</__uuid>
+ <__remote>false</__remote>
+ <__scriptlerScriptId>getTargets.groovy</__scriptlerScriptId>
+ <__parameters>
+ <com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerParameterDefinition_-ScriptParameter>
+ <name></name>
+ <value></value>
+ </com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerParameterDefinition_-ScriptParameter>
+ </__parameters>
+ <readonlyInputField>false</readonlyInputField>
+ <choiceType>PT_SINGLE_SELECT</choiceType>
+ </com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerChoiceParameterDefinition>
+ <hudson.model.BooleanParameterDefinition>
+ <name>Target_Cleanup</name>
+ <description></description>
+ <defaultValue>true</defaultValue>
+ </hudson.model.BooleanParameterDefinition>
+ <com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerChoiceParameterDefinition plugin="dynamicparameter@0.2.1-SNAPSHOT">
+ <name>TESTPLAN</name>
+ <description></description>
+ <__uuid>489363e5-bf6c-408b-96b4-fe3ad75bc002</__uuid>
+ <__remote>false</__remote>
+ <__scriptlerScriptId>getTestplans.groovy</__scriptlerScriptId>
+ <__parameters>
+ <com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerParameterDefinition_-ScriptParameter>
+ <name>test_name</name>
+ <value>CIAT.build_deploy</value>
+ </com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerParameterDefinition_-ScriptParameter>
+ </__parameters>
+ <readonlyInputField>false</readonlyInputField>
+ <choiceType>PT_SINGLE_SELECT</choiceType>
+ </com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerChoiceParameterDefinition>
+ </parameterDefinitions>
+ </hudson.model.ParametersDefinitionProperty>
+ <hudson.plugins.sidebar__link.ProjectLinks plugin="sidebar-link@1.6">
+ <links>
+ <hudson.plugins.sidebar__link.LinkAction>
+ <url>/userContent/docs/jta-docs.pdf</url>
+ <text>Documentation</text>
+ <icon>help.gif</icon>
+ </hudson.plugins.sidebar__link.LinkAction>
+ </links>
+ </hudson.plugins.sidebar__link.ProjectLinks>
+ <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@1.6">
+ <maxConcurrentPerNode>0</maxConcurrentPerNode>
+ <maxConcurrentTotal>0</maxConcurrentTotal>
+ <throttleEnabled>false</throttleEnabled>
+ </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
+ </properties>
+ <scm class="hudson.scm.NullSCM"/>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+ <triggers class="vector"/>
+ <concurrentBuild>true</concurrentBuild>
+ <customWorkspace>/home/jenkins/buildzone</customWorkspace>
+ <builders>
+ <hudson.tasks.Shell>
+ <command>if [ ! -d &quot;$JTA_LOGS_PATH/$JOB_NAME&quot; ]; then mkdir -p &quot;$JTA_LOGS_PATH/$JOB_NAME&quot;; fi
+ echo $TESTPLAN &gt;$JTA_LOGS_PATH/$JOB_NAME/last_used_testplan;
+ TESTPLAN=testplans/$TESTPLAN.json
+
+ source $JTA_TESTS_PATH/$JOB_NAME/build_deploy.sh</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers>
+ <hudson.plugins.postbuildtask.PostbuildTask plugin="postbuild-task@1.8">
+ <tasks>
+ <hudson.plugins.postbuildtask.TaskProperties>
+ <logTexts>
+ <hudson.plugins.postbuildtask.LogProperties>
+ <logText>ssh</logText>
+ <operator>AND</operator>
+ </hudson.plugins.postbuildtask.LogProperties>
+ </logTexts>
+ <EscalateStatus>true</EscalateStatus>
+ <RunIfJobSuccessful>false</RunIfJobSuccessful>
+ <script>source $JTA_SCRIPTS_PATH/functions.sh;&#xd;
+post_test $TESTDIR&#xd;
+</script>
+ </hudson.plugins.postbuildtask.TaskProperties>
+ </tasks>
+ </hudson.plugins.postbuildtask.PostbuildTask>
+ <org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder plugin="groovy-postbuild@1.6-SNAPSHOT">
+ <groovyScript>Binding binding = new Binding();
+binding.setVariable(&quot;manager&quot;, manager);
+GroovyShell shell = new GroovyShell(binding);
+shell.evaluate(new File(&quot;/home/jenkins/scripts/postbuild.groovy&quot;).text);</groovyScript>
+ <behavior>0</behavior>
+ </org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder>
+ </publishers>
+ <buildWrappers>
+ <hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="build-timeout@1.11">
+ <timeoutMinutes>240</timeoutMinutes>
+ <failBuild>false</failBuild>
+ <writingDescription>false</writingDescription>
+ <timeoutPercentage>0</timeoutPercentage>
+ <timeoutType>absolute</timeoutType>
+ <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
+ </hudson.plugins.build__timeout.BuildTimeoutWrapper>
+ <org.jvnet.hudson.plugins.exclusion.IdAllocator plugin="Exclusion@0.8">
+ <ids>
+ <org.jvnet.hudson.plugins.exclusion.DefaultIdType>
+ <name>$JOB_NAME</name>
+ </org.jvnet.hudson.plugins.exclusion.DefaultIdType>
+ </ids>
+ </org.jvnet.hudson.plugins.exclusion.IdAllocator>
+ </buildWrappers>
+</project>