Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Merge cb2b4ee into 30fc616
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Hoang Dang committed Jun 30, 2018
2 parents 30fc616 + cb2b4ee commit 9825c6f
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 41 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
*.db
*.swp
*.swo
.tox/
.coverage
sktm.egg-info
.pytest_cache
18 changes: 7 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
language: python
python:
- "2.7"
env:
- TOX_ENV=py27,flake8,pylint
install:
- pip install -U pip
- pip install -r requirements.txt
- pip install -r test-requirements.txt
# Install sktm using pip to ensure dependencies are downloaded correctly.
- pip install .
- pip install coveralls tox
script:
# Make sure all Python files are loadable
- find -name '*.py' | xargs -l1 -IFILE python -c 'import imp; imp.load_source("", "FILE")'
# Check coding style
- flake8 --show-source .
- pylint tests
- coverage run --source=sktm,tests -m pytest -v -s .
- coverage report -m --omit="*/tests*"
- coveralls
- tox -e $TOX_ENV
- pip uninstall -y sktm
97 changes: 68 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ Install Kerberos client to enable `skt` authentication to Beaker:
Install `skt` dependencies following its
[README.md](https://github.com/RH-FMK/skt).

Run tests
---------

For running all tests write down:

python -m pytest -v -s tests

For running some specific tests you can do this as following:

python -m pytest -v -s tests/test_patchwork

Installation
------------

pip install git+https://github.com/RH-FMK/sktm

Setup
-----

Expand Down Expand Up @@ -252,10 +268,10 @@ Create the `~/.sktmrc` file telling sktm how to access Jenkins:
EOF

Clone sktm with Git, or simply download and unpack the latest "master" branch
archive. After that, you will be able to run the `sktm.py` executable
directly. The examples below assume you run it while being in the source root
directory, but any directory will do as long as the path to `sktm.py` is
correct.
archive. installs `sktm` by `pip install .`. After that, you will be able to
run the `sktm` executable directly. The examples below assume you run it while
being in the source root directory, but any directory will do as long as the
path to `sktm` is correct.

Usage
-----
Expand All @@ -268,7 +284,7 @@ the execution of Jenkins jobs sktm submits.
Before beginning testing a kernel branch, you need to establish a working
"baseline" commit, the patches would be applied on:

./sktm.py -v --jjname <JENKINS_PROJECT> baseline <GIT_REPO_URL> <GIT_REF>
sktm -v --jjname <JENKINS_PROJECT> baseline <GIT_REPO_URL> <GIT_REF>

Here, `<JENKINS_PROJECT>` would be the name of the Jenkins project running
skt, `<GIT_REPO_URL>` would be a kernel Git repository URL, and `<GIT_REF>`
Expand All @@ -278,15 +294,15 @@ locating a stable "baseline" commit, and usually will be a branch name.
E.g., following our setup example above, this command would find a baseline
commit in the current "scsi" tree:

./sktm.py -v --jjname sktm baseline \
git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git \
for-next
sktm -v --jjname sktm baseline \
git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git \
for-next

And this would do the same for the "net-next" tree:

./sktm.py -v --jjname sktm baseline \
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git \
master
sktm -v --jjname sktm baseline \
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git \
master

You will need to run the "baseline" command periodically to have your baseline
commits up-to-date, to allow newer patches to apply.
Expand All @@ -300,19 +316,19 @@ different commands for Patchwork v1 and v2 instances.

For Patchwork v1 run:

./sktm.py -v --jjname <JENKINS_PROJECT> patchwork \
<GIT_REPO_URL> \
<PATCHWORK_BASE_URL> <PATCHWORK_PROJECT> \
--lastpatch <PATCHWORK_PATCH_ID> \
--skip <PATTERN> [... <PATTERN>]
sktm -v --jjname <JENKINS_PROJECT> patchwork \
<GIT_REPO_URL> \
<PATCHWORK_BASE_URL> <PATCHWORK_PROJECT> \
--lastpatch <PATCHWORK_PATCH_ID> \
--skip <PATTERN> [... <PATTERN>]

and for Patchwork v2 run:

./sktm.py -v --jjname <JENKINS_PROJECT> patchwork \
<GIT_REPO_URL> \
--restapi <PATCHWORK_BASE_URL> <PATCHWORK_PROJECT> \
--lastpatch <PATCHWORK_TIMESTAMP> \
--skip <PATTERN> [... <PATTERN>]
sktm -v --jjname <JENKINS_PROJECT> patchwork \
<GIT_REPO_URL> \
--restapi <PATCHWORK_BASE_URL> <PATCHWORK_PROJECT> \
--lastpatch <PATCHWORK_TIMESTAMP> \
--skip <PATTERN> [... <PATTERN>]

Here, `<PATCHWORK_BASE_URL>` would be the base URL of the Patchwork instance,
`<PATCHWORK_PROJECT>` - the name of the Patchwork project to check for new
Expand All @@ -332,18 +348,18 @@ E.g. this command would test all patches after the one with ID 10363835, from
the "scsi" tree's Patchwork v1 instance, applying them onto the latest
baseline commit from the corresponding Git repo:

./sktm.py -v --jjname sktm patchwork \
git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git \
https://patchwork.kernel.org linux-scsi \
--lastpatch 10363835
sktm -v --jjname sktm patchwork \
git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git \
https://patchwork.kernel.org linux-scsi \
--lastpatch 10363835

And this one would test all patches received by the "next-next" tree's
Patchwork v2 instance after `Thu, 3 May 2018 14:35:00 +0100` timestamp:

./sktm.py -v --jjname sktm patchwork \
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git \
--restapi https://patchwork.ozlabs.org netdev \
--lastpatch 'Thu, 3 May 2018 14:35:00 +0100'
sktm -v --jjname sktm patchwork \
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git \
--restapi https://patchwork.ozlabs.org netdev \
--lastpatch 'Thu, 3 May 2018 14:35:00 +0100'

Note: do not run the commands above with the `--lastpatch` option value
intact, as that would likely result in a lot of Jenkins jobs submitted,
Expand Down Expand Up @@ -374,6 +390,29 @@ is being applied, the command will be

sqlite3 ~/.sktm.db < 01-pending.sql

Developer Guide
---------------

Developers can test changes to `sktm` by using "development mode" from python's
`setuptools` package. First, `cd` to the directory where `sktm` is cloned and
run:

pip install --user -e .

This installs `sktm` in a mode where any changes within the repo are
immediately available simply by running `sktm`. There is no need to repeatedly
run `pip install .` after each change.

Using a virtual environment is highly recommended. This keeps `sktm` and all
its dependencies in a separate Python environment. Developers can build a
virtual environment for sktm quickly:

virtualenv ~/sktm-venv/
source ~/sktm-venv/bin/activate
pip install -e .

To deactivate the virtual environment, simply run `deactivate`.


License
-------
Expand Down
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[metadata]
name = sktm
description = "Sonic Kernel Testing Manager"
long_description = file: README.md
version = 1
author = Red Hat, Inc.
license = GPLv2+

[options]
# Automatically find all files beneath the sktm directory and include them.
packages = find:
# Parse the MANIFEST.in file and include those files, too.
include_package_data = True

install_requires = flake8
dateutils
enum34
jenkinsapi
junit_xml
requests
pylint
mock

[options.entry_points]
console_scripts =
sktm = sktm.executable:main

[options.packages.find]
# Don't include the /tests directory when we search for python files.
exclude =
tests
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
# Copyright (c) 2018 Red Hat, Inc. All rights reserved. This copyrighted
# material is made available to anyone wishing to use, modify, copy, or
# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2 or later.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Install sktm using setuptools."""
from setuptools import setup

setup()
6 changes: 5 additions & 1 deletion sktm.py → sktm/executable.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def load_config(args):
return cfg


if __name__ == '__main__':
def main():
"""Handle the execution of sktm"""
parser = setup_parser()
args = parser.parse_args()

Expand All @@ -138,3 +139,6 @@ def load_config(args):
except KeyboardInterrupt:
logging.info("Quitting...")
sw.cleanup()

if __name__ == '__main__':
main()
31 changes: 31 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tox]
envlist =
py27
flake8
pylint

[testenv]
passenv = TRAVIS TRAVIS_*
deps =
coverage
mock
coveralls
pytest
commands =
coverage run --branch --source=sktm -m pytest -v -s tests
coverage report -m
coveralls

[testenv:flake8]
passenv = CI TRAVIS TRAVIS_*
basepython =
python2.7
commands =
flake8 --show-source .

[testenv:pylint]
passenv = CI TRAVIS TRAVIS_*
basepython =
python2.7
commands =
pylint tests

0 comments on commit 9825c6f

Please sign in to comment.