From 6d8535009af27fa0c6b02ec0f3da684c4bbb8124 Mon Sep 17 00:00:00 2001 From: dkhandel Date: Fri, 11 May 2018 12:58:09 +0530 Subject: [PATCH 1/3] JJB job for running the functional test from glusterfs-coreutils against glusterfs --- gluster_coreutils.yml | 45 +++++++++++++++++++++++++++++++++++++++ scripts/jenkins-job.py | 48 ++++++++++++++++++++++++++++++++++++++++++ scripts/run-test.sh | 29 +++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 gluster_coreutils.yml create mode 100644 scripts/jenkins-job.py create mode 100755 scripts/run-test.sh diff --git a/gluster_coreutils.yml b/gluster_coreutils.yml new file mode 100644 index 0000000..74d669a --- /dev/null +++ b/gluster_coreutils.yml @@ -0,0 +1,45 @@ +- job: + name: gluster_coreutils + node: gluster + description: Run the functional test from glusterfs-coreutils against the latest + build of the glusterfs packages. A new run is executed automatically against + the nightly builds of the master branch. + project-type: freestyle + + + builders: + - shell: |- + curl -o jenkins-job.py ${DUFFY_SCRIPT} + python jenkins-job.py + + properties: + - github: + url: https://github.com/gluster/glusterfs-coreutils/ + + + parameters: + - string: + default: scripts/jenkins-job.py + description: Python script that reserves a machine from Duffy. + name: DUFFY_SCRIPT + - string: + default: scripts/run-test.sh + description: Test script to execute on the reserved machine. + name: TEST_SCRIPT + + + triggers: + - pollurl: + cron: H */2 * * * + polling-node: gluster + urls: + - url: http://artifacts.ci.centos.org/gluster/nightly/master/7/x86_64/repodata/repomd.xml + check-date: true + timeout: 300 + check-status: 200 + + + wrappers: + - timestamps + - ansicolor: + colormap: xterm diff --git a/scripts/jenkins-job.py b/scripts/jenkins-job.py new file mode 100644 index 0000000..49f9ec7 --- /dev/null +++ b/scripts/jenkins-job.py @@ -0,0 +1,48 @@ +# +# from: https://raw.githubusercontent.com/kbsingh/centos-ci-scripts/master/build_python_script.py +# +# This script uses the Duffy node management api to get fresh machines to run +# your CI tests on. Once allocated you will be able to ssh into that machine +# as the root user and setup the environ +# +# XXX: You need to add your own api key below, and also set the right cmd= line +# needed to run the tests +# +# Please note, this is a basic script, there is no error handling and there are +# no real tests for any exceptions. Patches welcome! + +import json, urllib, subprocess, sys, os + +print "" +print "This test is part of the Gluster Jenkins jobs that can be found on GitHub:" +print " - https://github.com/gluster/glusterfs-patch-acceptance-tests/tree/master/centos-ci" +print "" + +url_base="http://admin.ci.centos.org:8080" +ver="7" +arch="x86_64" +count=1 +script_url=os.getenv("TEST_SCRIPT") + +# read the API key for Duffy from the ~/duffy.key file +fo=open("/home/gluster/duffy.key") +api=fo.read().strip() +fo.close() + +# build the URL to request the system(s) +get_nodes_url="%s/Node/get?key=%s&ver=%s&arch=%s&count=%s" % (url_base,api,ver,arch,count) + +# request the system +dat=urllib.urlopen(get_nodes_url).read() +b=json.loads(dat) +cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' + yum -y install curl && + curl %s | bash - +'""" % (b['hosts'][0], script_url) +rtn_code=subprocess.call(cmd, shell=True) + +# return the system(s) to duffy +done_nodes_url="%s/Node/done?key=%s&ssid=%s" % (url_base, api, b['ssid']) +das=urllib.urlopen(done_nodes_url).read() + +sys.exit(rtn_code) diff --git a/scripts/run-test.sh b/scripts/run-test.sh new file mode 100755 index 0000000..a8cd50a --- /dev/null +++ b/scripts/run-test.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# error out on any failure +set -e + +# install EPEL (for "bats") and standard Gluster repo +yum -y install epel-release centos-release-gluster yum-utils + +# enable the repository with nightly builds (master branch only, for now) +yum-config-manager --add-repo=http://artifacts.ci.centos.org/gluster/nightly/master.repo + +# Install and start gluster daemon +yum -y install glusterfs-server +systemctl start glusterd + +# Install dependencies for glusterfs-coreutils and the tests +yum -y install git help2man python-gluster readline-devel glusterfs-api-devel libtool bats + +# Git clone the source code +git clone https://github.com/gluster/glusterfs-coreutils.git + +# Install glusterfs-coreutils from source +cd glusterfs-coreutils/ +./autogen.sh +./configure +make -j && make install + +# Run test script +./run-tests.sh From 6fc0dbe2f8e71f95afe9a116f359776b9d8a30a7 Mon Sep 17 00:00:00 2001 From: dkhandel Date: Fri, 11 May 2018 12:58:09 +0530 Subject: [PATCH 2/3] JJB job for running the functional test from glusterfs-coreutils against glusterfs --- gluster_coreutils.yml | 45 ++++++++++++++++++++++++++++++++ scripts/common/jenkins-job.py | 48 +++++++++++++++++++++++++++++++++++ scripts/common/run-test.sh | 29 +++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 gluster_coreutils.yml create mode 100644 scripts/common/jenkins-job.py create mode 100755 scripts/common/run-test.sh diff --git a/gluster_coreutils.yml b/gluster_coreutils.yml new file mode 100644 index 0000000..da9d074 --- /dev/null +++ b/gluster_coreutils.yml @@ -0,0 +1,45 @@ +- job: + name: gluster_coreutils + node: gluster + description: Run the functional test from glusterfs-coreutils against the latest + build of the glusterfs packages. A new run is executed automatically against + the nightly builds of the master branch. + project-type: freestyle + + + builders: + - shell: |- + curl -o jenkins-job.py ${DUFFY_SCRIPT} + python jenkins-job.py + + properties: + - github: + url: https://github.com/gluster/glusterfs-coreutils/ + + + parameters: + - string: + default: scripts/common/jenkins-job.py + description: Python script that reserves a machine from Duffy. + name: DUFFY_SCRIPT + - string: + default: scripts/common/run-test.sh + description: Test script to execute on the reserved machine. + name: TEST_SCRIPT + + + triggers: + - pollurl: + cron: H */2 * * * + polling-node: gluster + urls: + - url: http://artifacts.ci.centos.org/gluster/nightly/master/7/x86_64/repodata/repomd.xml + check-date: true + timeout: 300 + check-status: 200 + + + wrappers: + - timestamps + - ansicolor: + colormap: xterm diff --git a/scripts/common/jenkins-job.py b/scripts/common/jenkins-job.py new file mode 100644 index 0000000..49f9ec7 --- /dev/null +++ b/scripts/common/jenkins-job.py @@ -0,0 +1,48 @@ +# +# from: https://raw.githubusercontent.com/kbsingh/centos-ci-scripts/master/build_python_script.py +# +# This script uses the Duffy node management api to get fresh machines to run +# your CI tests on. Once allocated you will be able to ssh into that machine +# as the root user and setup the environ +# +# XXX: You need to add your own api key below, and also set the right cmd= line +# needed to run the tests +# +# Please note, this is a basic script, there is no error handling and there are +# no real tests for any exceptions. Patches welcome! + +import json, urllib, subprocess, sys, os + +print "" +print "This test is part of the Gluster Jenkins jobs that can be found on GitHub:" +print " - https://github.com/gluster/glusterfs-patch-acceptance-tests/tree/master/centos-ci" +print "" + +url_base="http://admin.ci.centos.org:8080" +ver="7" +arch="x86_64" +count=1 +script_url=os.getenv("TEST_SCRIPT") + +# read the API key for Duffy from the ~/duffy.key file +fo=open("/home/gluster/duffy.key") +api=fo.read().strip() +fo.close() + +# build the URL to request the system(s) +get_nodes_url="%s/Node/get?key=%s&ver=%s&arch=%s&count=%s" % (url_base,api,ver,arch,count) + +# request the system +dat=urllib.urlopen(get_nodes_url).read() +b=json.loads(dat) +cmd="""ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@%s ' + yum -y install curl && + curl %s | bash - +'""" % (b['hosts'][0], script_url) +rtn_code=subprocess.call(cmd, shell=True) + +# return the system(s) to duffy +done_nodes_url="%s/Node/done?key=%s&ssid=%s" % (url_base, api, b['ssid']) +das=urllib.urlopen(done_nodes_url).read() + +sys.exit(rtn_code) diff --git a/scripts/common/run-test.sh b/scripts/common/run-test.sh new file mode 100755 index 0000000..a8cd50a --- /dev/null +++ b/scripts/common/run-test.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# error out on any failure +set -e + +# install EPEL (for "bats") and standard Gluster repo +yum -y install epel-release centos-release-gluster yum-utils + +# enable the repository with nightly builds (master branch only, for now) +yum-config-manager --add-repo=http://artifacts.ci.centos.org/gluster/nightly/master.repo + +# Install and start gluster daemon +yum -y install glusterfs-server +systemctl start glusterd + +# Install dependencies for glusterfs-coreutils and the tests +yum -y install git help2man python-gluster readline-devel glusterfs-api-devel libtool bats + +# Git clone the source code +git clone https://github.com/gluster/glusterfs-coreutils.git + +# Install glusterfs-coreutils from source +cd glusterfs-coreutils/ +./autogen.sh +./configure +make -j && make install + +# Run test script +./run-tests.sh From e1cc6e16abb510fc7a3ef7034f024ef143ec97e2 Mon Sep 17 00:00:00 2001 From: dkhandel Date: Fri, 18 May 2018 10:46:35 +0530 Subject: [PATCH 3/3] Refactor the code --- gluster_coreutils.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gluster_coreutils.yml b/gluster_coreutils.yml index da9d074..f1ad661 100644 --- a/gluster_coreutils.yml +++ b/gluster_coreutils.yml @@ -7,10 +7,16 @@ project-type: freestyle + scm: + - git: + url: https://github.com/gluster/centosci.git + branches: + - origin/master + + builders: - - shell: |- - curl -o jenkins-job.py ${DUFFY_SCRIPT} - python jenkins-job.py + - shell: !include-raw scripts/common/jenkins-job.py + properties: - github: @@ -18,10 +24,6 @@ parameters: - - string: - default: scripts/common/jenkins-job.py - description: Python script that reserves a machine from Duffy. - name: DUFFY_SCRIPT - string: default: scripts/common/run-test.sh description: Test script to execute on the reserved machine.