What is OpenStack CI ?
OpenStack CI is a Continuous Integration Testing environment used to run the tempest test suite on each local changes a developer submits to Gerrit against any specific OpenStack upstream project. This patch code submitted then goes through a lot of reviews and CI tests then gets megered into the main OpenStack project repository.
Why it is helpful ?
OpenStack CI is helpful in a lot of ways for developers by:
- Checking the stability of code.
- Helps in developing the code better.
How to Setup a CI ?
For setting up a CI follow the instructions:
Pre-requisites
Registering an Upstream Gerrit Account
- You will need to register a Gerrit account with the upstream OpenStack CI platform.
- You can read the instructions for doing that.
Ensure Basic Packages on Hosts/VMs
- We will be installing a Jenkins master server and infrastructure on one host or virtual machine and one or more Jenkins slave servers on hosts or VMs.
- On each of these target nodes, you will want the base image to have the
wget
,openssl
,ssl-cert
andca-certificates
packages installed before running anything in this repository.
Set Up Your Data Repository
- For more info on this refer CloudByte-CI-Data.
Installing CI Modules
To know more about which modules which be used refer CloudByte-CI-Modules.
Setting up the Jenkins Master
- On the machine you will use as your Jenkins master, run the following:
wget https://raw.github.com/CloudByteStorages/CloudByte-CI-Modules/master/puppet/install_master.sh
bash install_master.sh
-
The script will install Puppet, create an SSH key for the Jenkins master, create self-signed certificates for Apache, and then will ask you for the URL of the Git repository you are using as your data repository (see Prerequisites above).
-
Enter the URL of your data repository and hit Enter.
Puppet will proceed to set up the Jenkins master.
Manual setup of Jenkins scp 1.9 plugin
- Version 1.8 is publicly available, but does not have all features (e.g. copy console log file, copy files after failure, etc.).
- Follow these steps to manually build and install the scp 1.9 plugin:
- git clone https://github.com/jenkinsci/scp-plugin
- cd scp-plugin; mvn package
- Jenkins Manage Plugins; Advanced; Upload Plugin (target/scp.hpi from the maven build)
Restart Jenkins to get the plugins fully installed
sudo service jenkins restart
Load Jenkins Up with Your Jobs
- Run the following at the command line:
sudo jenkins-jobs --flush-cache update /etc/jenkins_jobs/config
Configuration
-
Start zuul
sudo service zuul start sudo service zuul-merger start
-
After Puppet installs Jenkins and Zuul and Nodepool, you will need to do a couple manual configuration steps in the Jenkins UI.
-
Go to the Jenkins web UI. By default, this will be
http://$IP_OF_MASTER:8080
-
Click the
Manage Jenkins
link on the left -
Click the
Configure System
link -
Scroll down until you see “Gearman Plugin Config”. Check the “Enable Gearman” checkbox.
- Click the “Test Connection” button and verify Jenkins connects to Gearman.
-
Scroll to “ZMQ Event Publisher” and select “Enable on all Jobs”. Double-check the port matches the URL configured for “zmq-publishers” in
$DATA_REPO/etc/nodepool/nodepool.yaml.erb
-
Scroll down to the bottom of the page and click
Save
-
At the command line, do this::
sudo service zuul restart
Setting up Static Jenkins Slaves
- On each machine you will use as a Jenkins slave, run:
wget https://raw.github.com/CloudByteStorages/CloudByte-CI-Modules/master/puppet/install_slave.sh
bash install_slave.sh
-
The script will install Puppet, install a Jenkins slave, and install the Jenkins master’s public SSH key in the
authorized_keys
of the Jenkins slave. -
Once the script completes successfully, you need to add the slave node to Jenkins master. To do so manually, follow these steps:
-
Go to the Jenkins web UI. By default, this will be
http://$IP_OF_MASTER:8080
-
Click the
Credentials
link on the left -
Click the
Global credentials
link -
Click the
Add credentials
link on the left -
Select
SSH username with private key
from the dropdown labeled “Kind” -
Enter “jenkins” in the
Username
textbox -
Select the “From a file on Jenkins master” radio button and enter
/var/lib/jenkins/.ssh/id_rsa
in the File textbox -
Click the
OK
button -
Click the “Jenkins” link in the upper left to go back to home page
-
Click the
Manage Jenkins
link on the left -
Click the
Manage Nodes
link -
Click the “New Node” link on the left
-
Enter
devstack_slave1
in theNode name
textbox -
Select the
Dumb Slave
radio button -
Click the
OK
button -
Enter
2
in theExecutors
textbox -
Enter
/home/jenkins/workspaces
in theRemote root directory
textbox -
Enter
devstack_slave
in theLabels
textbox -
Enter the IP Address of your slave host or VM in the
Host
textbox -
Select
jenkins
from theCredentials
dropdown -
Click the
Save
button -
Click the
Log
link on the left. The log should show the master connecting to the slave, and at the end of the log should be: “Slave successfully connected and online”
Setting up Log Server
- The Log server is a simple VM with an Apache web server installed that provides http access to all the log files uploaded by the jenkins jobs.
- It is a separate script because the jenkins-zuul-nodepool ‘master’ server may/can not be publicly accessible for security reasons.
- In addition, separating out the log server as its own server relaxes the disk space requirements needed by the jenkins master.
- It’s configuration uses the openstack-infra scripts, which provide the friendly log filtering features, hightlighting, the line references, etc.
- For simplicity, it is recommended to use the same jenkins key for authentication.
wget https://raw.githubusercontent.com/CloudByteStorages/CloudByte-CI-Modules/master/puppet/install_log_server.sh
# MANUALLY Update the LOG_SERVER_DOMAIN & JENKINS_SSH_PUBLIC_KEY_CONTENTS variables
bash install_log_server.sh
Bug:
err: /Stage[main]/Logging::Master/Exec[install_os-loganalyze]: Failed to call refresh: python setup.py install returned 1 instead of one of [0] at /home/stack/os-ext-testing/puppet/modules/logging/manifests/master.pp:89
Workaround:
cd /opt/os-loganalyze
sudo python setup.py install
- When completed, the jenkins user will be able to upload files to /srv/static/logs, which Apache will serve via http.