Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions cdrage-atomicapp-ci/centos-ci-jjb/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
name: centos-ci-bootstrap
builders:
- python:
!include-raw './run.py'
!include-raw:
- ./run.py

# Custom Trigger. Sets up the Github pull request trigger
# Accepts a parameter {provider}
Expand All @@ -26,7 +27,7 @@
- kadel
build-desc-template: "build description"
trigger-phrase: '#dotests|#dotest{provider}'
only-trigger-phrase: true
only-trigger-phrase: {only-trigger-phrase}
github-hooks: true
permit-all: false
auto-close-on-fail: false
Expand Down Expand Up @@ -64,22 +65,31 @@
clean:
after: true
credentials-id: 1d7dba44-5b34-42b3-886c-4d659ffb2aae
refspec: "{refspec}"
branches:
- "{branch}"

# job template for each provider to test against master
- job-template:
name: '{name}-{provider}-master'
# restrict to nodes that are set up for atomicapp
node: atomicapp-shared
properties:
- github:
url: "{git_repo_url}"
scm:
- custom-scm-git:
refspec: "{refspec}"
branch: "master"
publishers:
- custom-publisher-email
- custom-publisher-irc
builders:
- inject:
properties-content: |
#GIT_REPO_URL=https://github.com/dustymabe/adb-tests.git
GIT_REPO_URL=https://github.com/projectatomic/adb-tests.git
GIT_REPO_URL="{git_repo_url}"
MACHINE_COUNT=1
TEST_CMD='cd cdrage-atomicapp-ci/ && make install {provider} ATOMIC_SOURCE=rpm'
TEST_CMD='{test_cmd_master}'
- centos-ci-bootstrap

# job template for each provider to test PRs using GHPRB
Expand All @@ -89,21 +99,26 @@
node: atomicapp-shared
properties:
- github:
url: https://github.com/projectatomic/atomicapp
url: "{git_repo_url}"
scm:
- custom-scm-git:
refspec: "{refspec}"
branch: "{branch}"
triggers:
- custom-trigger:
provider: "{provider}"
only-trigger-phrase: {only-trigger-false}

publishers:
- custom-publisher-email
- custom-publisher-irc
builders:
- inject:
properties-content: |
PROVIDER={provider}
#GIT_REPO_URL=https://github.com/dustymabe/adb-tests.git
GIT_REPO_URL=https://github.com/projectatomic/adb-tests.git
GIT_REPO_URL="{git_repo_url}"
MACHINE_COUNT=1
TEST_CMD='cd cdrage-atomicapp-ci/ && make install {provider} ATOMICAPP_PR=$ghprbPullId ATOMIC_SOURCE=rpm'
TEST_CMD = '{test_cmd}'
- centos-ci-bootstrap

# create the jobs using the job templates
Expand All @@ -113,6 +128,18 @@
- docker
- kubernetes
- openshift
- unittest:
git_repo_url: "https://github.com/projectatomic/atomicapp"
refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
branch: "${{sha1}}"
test_cmd_master: 'make test'
test_cmd: 'make test'
refspec: ""
branch: ""
only-trigger-phrase: true
git_repo_url: https://github.com/projectatomic/adb-tests.git
test_cmd: 'cd cdrage-atomicapp-ci/ && make install {provider} ATOMICAPP_PR=$ghprbPullId ATOMIC_SOURCE=rpm'
test_cmd_master: 'cd cdrage-atomicapp-ci/ && make install {provider} ATOMIC_SOURCE=rpm'
jobs:
- '{name}-{provider}-pr'
- '{name}-{provider}-master'
55 changes: 52 additions & 3 deletions cdrage-atomicapp-ci/centos-ci-jjb/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
url_base = "http://admin.ci.centos.org:8080"
api_key = os.environ['CICO_API_KEY'] # comes from node environment vars
count = os.environ['MACHINE_COUNT']
workspace = os.environ['WORKSPACE']
provider = os.environ['PROVIDER']
ver = "7"
arch = "x86_64"
req_url = "%s/Node/get?key=%s&ver=%s&arch=%s&count=%s" % (url_base,api_key,ver,arch,count)
req_url = "%s/Node/get?key=%s&ver=%s&arch=%s&i_count=%s" % (url_base,api_key,ver,arch,count)

# The git repo url of the project for us to clone
git_repo_url = os.environ['GIT_REPO_URL']
Expand All @@ -22,8 +24,47 @@
# load into a dictionary
data = json.loads(jsondata)

# Iterate through the returned hosts and run the tests on it
for host in data['hosts']:
def run_unittest(host):
scp_cmd = "scp "
scp_cmd += "-o UserKnownHostsFile=/dev/null "
scp_cmd += "-o StrictHostKeyChecking=no -r "
scp_cmd += "%s root@%s:/tmp/test" % (workspace, host)

# Build the ssh part of the cmd to send
ssh_cmd = "ssh -t -t " # Force psuedo tty allocation - need two -t
ssh_cmd += "-o UserKnownHostsFile=/dev/null " # Don't store host info
ssh_cmd += "-o StrictHostKeyChecking=no " # Don't ask yes/no
ssh_cmd += "root@%s " % (host) # Log in as root on the host

# Build up cmd to run on the remote duffy instance
# - Install git
# - Create and change to temporary directory
# - Clone remote repo
# - Finally run user specified test cmd
remote_cmd = "cd /tmp/test && "
remote_cmd += 'yum install -y git epel-release && '
remote_cmd += 'yum install -y python-pip && '
remote_cmd += "pip install pytest-cov coveralls && "
remote_cmd += "pip install pep8 && "
remote_cmd += "pip install flake8 && "
remote_cmd += "make install && "
remote_cmd += "make syntax-check && "
remote_cmd += "bash -c %s " % test_cmd

print "Copying checked out repository to host: {}".format(scp_cmd)
exit_code = subprocess.call(scp_cmd, shell=True)

cmd = '%s "%s"' % (ssh_cmd, remote_cmd)
print("Running cmd: {}".format(cmd))
exit_code = subprocess.call(cmd, shell=True)

# Send a rest request to release the node
done_nodes_url = "%s/Node/done?key=%s&ssid=%s" % (url_base, api_key, data['ssid'])
print urllib.urlopen(done_nodes_url).read()
return exit_code


def run(host):
# Build the ssh part of the cmd to send
ssh_cmd = "ssh -t -t " # Force psuedo tty allocation - need two -t
ssh_cmd += "-o UserKnownHostsFile=/dev/null " # Don't store host info
Expand All @@ -47,4 +88,12 @@
# Send a rest request to release the node
done_nodes_url="%s/Node/done?key=%s&ssid=%s" % (url_base, api_key, data['ssid'])
print urllib.urlopen(done_nodes_url).read()
return exit_code

# Iterate through the returned hosts and run the tests on it
for host in data['hosts']:
if provider == 'unittest':
exit_code = run_unittest(host)
else:
exit_code = run(host)
sys.exit(exit_code)