Skip to content

Commit

Permalink
Merge pull request #117 from fedora-modularity/devel
Browse files Browse the repository at this point in the history
Merge devel branch into master
  • Loading branch information
phracek authored Oct 3, 2017
2 parents 8793e11 + d47e37a commit ec135f9
Show file tree
Hide file tree
Showing 82 changed files with 1,294 additions and 1,606 deletions.
2 changes: 1 addition & 1 deletion .tito/packages/meta-test-family
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.1-1 ./
0.7.3-1 ./
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ services:

before_install:
- sudo apt-get -y install curl python-software-properties software-properties-common python-pip python-dev build-essential git make
- sudo apt-get install -y libkrb5-dev
- sudo apt-get -y install libkrb5-dev netcat mysql-client-5.5
- sudo pip install avocado-framework
- pip install avocado-framework

install: sudo make install

script: sudo make travis
script:
- sudo make -C examples/testing-module check-inheritance
- sudo make -C examples/testing-module check-default-config
- sudo make -C examples/testing-module check-pure-docker
- sudo make -C examples/testing-module check-exceptions
- sudo make -C examples/testing-module check-test-mtf-bin-modulelint
- sudo make travis
- sudo make -C examples/testing-module check-real-rpm-destructive
- sudo make -C examples/testing-module check-docker-scl-multi-travis

after_script: sudo cat ~/avocado/job-results/latest/job.log
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include LICENSE
include Vagrantfile
include README.md
include CONTRIBUTING.md
include requirements.txt
recursive-include moduleframework *
recursive-include docs *
recursive-include examples *
Expand Down
15 changes: 9 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

Vagrant.configure(2) do |config|

config.vm.box = "fedora/25-cloud-base"
config.vm.synced_folder ".", "/home/vagrant/meta-test-family"
config.vm.box = "fedora/26-cloud-base"
config.vm.synced_folder ".", "/opt/meta-test-family"
config.vm.network "private_network", ip: "192.168.50.10"
config.vm.network "forwarded_port", guest: 80, host: 8888
config.vm.hostname = "moduletesting"
Expand All @@ -43,14 +43,17 @@ Vagrant.configure(2) do |config|

config.vm.provision "shell", inline: <<-SHELL
set -x
dnf install -y make docker httpd git python2-avocado python2-avocado-plugins-output-html python-netifaces
cd /home/vagrant/meta-test-family
TARGET=#{ENV['TARGET']}
test -z "$TARGET" && TARGET=check-docker
dnf install -y make docker httpd git python2-avocado python2-avocado-plugins-output-html \
python-netifaces redhat-rpm-config python2-devel python-gssapi krb5-devel
cd /opt/meta-test-family
make install
make check
make -C examples/testing-module $TARGET
cp -r /root/avocado /var/www/html/
chmod -R a+x /var/www/html/
restorecon -r /var/www/html/
systemctl start httpd
SHELL
end
6 changes: 0 additions & 6 deletions docs/api/bashhelper.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/example-config-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ packages:
- bash
module:
docker:
container: docker.io/modularitycontainers/memcached
container: fedora
rpm:
repo: https://kojipkgs.fedoraproject.org/compose/latest-Fedora-Modular-26/compose/Server/x86_64/os/
17 changes: 16 additions & 1 deletion docs/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ packages:
testdependencies:
rpms:
- nc
# default module type for testing if not set by env variable
# default module type for testing if not set by env variable.
# This dependencies are installed by mtf-set-env script
# env var: MODULE (docker, nspawn, rpm)
default_module: docker
# various module types setup and configuration (nspawn = rpm)
Expand All @@ -60,6 +61,9 @@ module:
# tag(gz) archive local path, or docker=cotainer_name for image already imported image
# env var: URL
# MANDATORY
url: docker.io/modularitycontainers/memcached
# same meaning as url
# OBSOLOTE
container: docker.io/modularitycontainers/memcached
# rpm section (nspawn) There is similar meaning like docker seciton, but for rpm(nspawn)
# MANDATORY
Expand All @@ -74,6 +78,9 @@ module:
# use "compose", this will be ignored
# env var: URL
# MANDATORY
url: https://kojipkgs.fedoraproject.org/compose/latest-Fedora-Modular-26/compose/Server/x86_64/os/
# same meaing as url
# OBSOLOTE
repo: https://kojipkgs.fedoraproject.org/compose/latest-Fedora-Modular-26/compose/Server/x86_64/os/
# if you will not use "compose" nor repo, you can use repos, which caused that just mentioned
# repos will be used, not additional repos from moduleMD file
Expand All @@ -82,3 +89,11 @@ module:
repos:
- https://kojipkgs.stg.fedoraproject.org/compose/branched/jkaluza/latest-Fedora-Modular-26/compose/Server/x86_64/os/
- https://kojipkgs.fedoraproject.org/compose/latest-Fedora-Modular-26/compose/Server/x86_64/os/
# If you would like to have more configs for same module type, it is possible to do it via inheritance
# There will be used parent module + overwritten values with this one, you can rewrite whatever you want.
# you have to set parent (base) module type allowed are just
# rpm/docker
inheriteddocker:
# you have to set parent value for these inherited configs
parent: docker
start: "docker run -it -p 11211:11211"
2 changes: 2 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ After preparing the libvirt prerequisites using the instructions above:
# Provision the Vagrant environment:
$ sudo vagrant up --provider=libvirt # or just `sudo vagrant up` as libvirt is a default one
# Alternatively, set the TARGET envvar to test another target defined in examples/testing-module/Makefile
$ sudo TARGET=check-pure-docker vagrant up
# The above will run for a while while it provisions your development environment.
$ sudo vagrant reload # Reboot the machine at the end to apply kernel updates, etc.
Expand Down
4 changes: 3 additions & 1 deletion docs/user_guide/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Environment variables allow to overwrite some values of a module configuration f
- **MODULEMDURL** overwrites the location of a moduleMD file.
- **COMPOSEURL** overwrites the location of a compose Pungi build.
- **MTF_SKIP_DISABLING_SELINUX=yes** does not disable SELinux. In nspawn type on Fedora 25 SELinux should be disabled, because it does not work well with SELinux enabled, this option allows to not do that.
- **MTF_DO_NOT_CLEANUP=yes** does not clean up modules between tests. It speeds up test execution. Use only if there is no interference between tests.
- **MTF_DO_NOT_CLEANUP=yes** does not clean up module after tests execution (a machine remains running).
- **MTF_REUSE=yes** uses the same module between tests. It speeds up test execution. It can cause side effects.
- **MTF_REMOTE_REPOS=yes** disables downloading of Koji packages and creating a local repo, and speeds up test execution.
- **MTF_DISABLE_MODULE=yes** disables module handling to use nonmodular test mode (see `multihost tests`_ as an example).

.. _multihost tests: https://github.com/fedora-modularity/meta-test-family/tree/devel/examples/multios_testing


.. seealso::

:doc:`index`
Expand Down
16 changes: 9 additions & 7 deletions docs/user_guide/how_to_write_conf_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,28 @@ An example of module types specification:
description: "memcached is a high-performance, distributed memory"
io.k8s.description: "memcached is a high-performance, distributed memory"
source: https://github.com/container-images/memcached.git
container: docker.io/phracek/memcached
url: docker.io/phracek/memcached
rpm:
setup: /usr/bin/memcached -p 11211
cleanup: echo Cleanup magic
start: systemctl start memcached
stop: systemctl stop memcached
status: systemctl status memcached
repo:
- http://download.englab.brq.redhat.com/pub/fedora/releases/25/Everything/x86_64/os/
- https://phracek.fedorapeople.org/memcached-module-repo/
url: http://download.englab.brq.redhat.com/pub/fedora/releases/25/Everything/x86_64/os/
inheriteddocker:
parent: docker
start: "docker run -it -p 11211:11211"
* **default_module**, if specified, sets the default tested module type
* **setup** runs setup commands on a host machine, not in container, and prepares the environemt for tests, for example changes selinux policy or hostname
* **cleanup**: similar to setup but done after test finished
* **start** defines how to start module service if there is any
* **stop** defines how to stop module service if there is any
* **status** defines how to check the status of module service if there is any
* **labels** contains docker labels to check if there is any
* **container** contains a link to a container (docker.io or local tar.gz file)
* **repo** is used when **compose-url** is not set and contains a repo to be used for rpm module type testing
* **url** contains link to a container or repo (same meaning as container or repo)
* **container** contains a link to a container (docker.io or local tar.gz file) (obsolote)
* **repo** is used when **compose-url** is not set and contains a repo to be used for rpm module type testing (obsolote)
* **parent** if you would like to have more configs for same module type, it is possible to do it via inheritance. There will be used parent module + overwritten values with this one, you can rewrite whatever you want. You have to set parent (base) module type allowed are just **rpm/docker**

Multiline Bash snippet tests
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
User Guide
==========

1. In a module's root directory create a directory ``tests`` and place there a module configuration file ``config.yaml`` described in detail in section `Configuration file`_.
1. In a module's root directory create a directory ``tests`` and place there a module configuration file ``config.yaml`` described in detail in section `Configuration file`_. If you would like to use MTF without your own ``config.yaml``. It is possible. It uses default minimal config. Then you have to set ``URL`` envvar to set `test subject`, otherwise it causes traceback. It is usefull for example for module what does not provide any service (no own ``start/stop/status/etc`` action defined.) or for testing with modulelint.

.. _Configuration file: how_to_write_conf_file.html

Expand Down
5 changes: 3 additions & 2 deletions docs/user_guide/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ First test takes so long time
It is expected behavior, because the first test run downloads all packages from Koji and creates a local
repo. It is workaround because of missing composes for modules (on demand done by pungi). To make tests execute faster use environment variables:

- **MTF_REMOTE_REPOS=yes** - It heps in case there are repos in koji https://kojipkgs.fedoraproject.org/repos/ (they are there just temporary, deleted after 2 weeks and probably it will not be created in near future anyhow)
- **MTF_DO_NOT_CLEANUP=yes** to disable cleaup between tests. Use only if there is no interference in between tests.
- **MTF_DO_NOT_CLEANUP=yes** does not clean up module after tests execution (a machine remains running).
- **MTF_REUSE=yes** uses the same module between tests. It speeds up test execution. It can cause side effects.
- **MTF_REMOTE_REPOS=yes** disables downloading of Koji packages and creating a local repo, and speeds up test execution.

Unable to debug avocado output errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
16 changes: 16 additions & 0 deletions examples/alternative_frameworks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export MTF_REMOTE_REPOS=yes
export DEBUG=yes
export MODULE=docker

prepare-docker:
dnf -y install pytest python2-case
mtf-env-set

check-nosetest: prepare-docker
nosetests

check-unittest: prepare-docker
python -m unittest example_unittest

check-pytest: prepare-docker
pytest -q example_pytest.py
11 changes: 11 additions & 0 deletions examples/alternative_frameworks/example_pytest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest
from moduleframework import module_framework


def test_simple():
backend, moduletype = module_framework.get_backend()
backend.setUp()
backend.start()
assert "bin" in backend.run("ls /").stdout
backend.tearDown()

18 changes: 18 additions & 0 deletions examples/alternative_frameworks/example_unittest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import unittest
from moduleframework import module_framework

class TestSimple(unittest.TestCase):

def setUp(self):
self.backend, self.moduletype = module_framework.get_backend()
self.backend.setUp()
self.backend.start()

def tearDown(self):
self.backend.tearDown()

def test_simple(self):
self.assertIn("bin", self.backend.run("ls /").stdout)

if __name__ == '__main__':
unittest.main()
21 changes: 21 additions & 0 deletions examples/alternative_frameworks/test_nosetest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from moduleframework import module_framework


def test_simple():
backend, moduletype = module_framework.get_backend()
backend.setUp()
backend.start()
assert "bin" in backend.run("ls /").stdout
backend.tearDown()

class TestExampleTwo:
def setUp(self):
self.backend, self.moduletype = module_framework.get_backend()
self.backend.setUp()
self.backend.start()

def test_simpleinclass(self):
assert "bin" in self.backend.run("ls /").stdout

def tearDown(self):
self.backend.tearDown()
14 changes: 0 additions & 14 deletions examples/base-runtime/config.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions examples/base-runtime/resources/base-runtime-mock.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions examples/base-runtime/resources/hello-world/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions examples/base-runtime/resources/hello-world/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions examples/base-runtime/resources/hello-world/hello.c

This file was deleted.

7 changes: 0 additions & 7 deletions examples/base-runtime/resources/hello-world/hello.sh

This file was deleted.

Loading

0 comments on commit ec135f9

Please sign in to comment.