Dockerfile based on BRT, test suite for module
This commit is contained in:
parent
398481abed
commit
ba9d082c94
22 changed files with 1007 additions and 0 deletions
6
tests/Makefile
Normal file
6
tests/Makefile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
MODULE_LINT=/usr/share/moduleframework/tools/modulelint.py
|
||||
CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py
|
||||
|
||||
#
|
||||
all:
|
||||
$(CMD)
|
||||
14
tests/config.yaml
Normal file
14
tests/config.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
document: modularity-testing
|
||||
version: 1
|
||||
name: postgresql
|
||||
modulemd-url: https://src.fedoraproject.org/cgit/modules/postgresql.git/plain/postgresql.yaml
|
||||
service:
|
||||
port: 5432
|
||||
module:
|
||||
docker:
|
||||
start: "docker run -it -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=p -e POSTGRESQL_DATABASE=db -e LC_ALL=C -p 5432:5432"
|
||||
container: postgresql
|
||||
rpm:
|
||||
start: run-postgresql
|
||||
repos:
|
||||
- http://mirror.vutbr.cz/fedora/releases/26/Everything/x86_64/os/
|
||||
56
tests/rpmvalidator.py
Normal file
56
tests/rpmvalidator.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This Modularity Testing Framework helps you to write tests for modules
|
||||
# Copyright (C) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# he Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Authors: Jan Scotka <jscotka@redhat.com>
|
||||
#
|
||||
|
||||
from avocado import main
|
||||
from moduleframework import module_framework
|
||||
|
||||
|
||||
class ExampleRpmValidation(module_framework.AvocadoTest):
|
||||
"""
|
||||
:avocado: enable
|
||||
"""
|
||||
fhs_base_paths = [
|
||||
'/bin',
|
||||
'/boot',
|
||||
'/dev',
|
||||
'/etc',
|
||||
'/home',
|
||||
'/lib',
|
||||
'/lib64',
|
||||
'/media',
|
||||
'/mnt',
|
||||
'/opt',
|
||||
'/proc',
|
||||
'/root',
|
||||
'/run',
|
||||
'/sbin',
|
||||
'/sys',
|
||||
'/srv',
|
||||
'/tmp',
|
||||
'/usr/bin'
|
||||
]
|
||||
|
||||
def testPaths(self):
|
||||
self.start()
|
||||
for directory in self.fhs_base_paths:
|
||||
self.run("test -d %s" % directory)
|
||||
46
tests/sanity1.py
Normal file
46
tests/sanity1.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This Modularity Testing Framework helps you to write tests for modules
|
||||
# Copyright (C) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# he Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
||||
#
|
||||
|
||||
from avocado import main
|
||||
from avocado.core import exceptions
|
||||
from moduleframework import module_framework
|
||||
|
||||
|
||||
class SanityCheck1(module_framework.AvocadoTest):
|
||||
"""
|
||||
:avocado: enable
|
||||
"""
|
||||
|
||||
def test1(self):
|
||||
self.start()
|
||||
self.run("ls / | grep bin")
|
||||
|
||||
# check if perl is installed in the right version.
|
||||
def test2PostgresVersion(self):
|
||||
postgresVersion = "9.6"
|
||||
self.start()
|
||||
self.run("postgres --version | grep " + postgresVersion)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
47
tests/sanity2.py
Normal file
47
tests/sanity2.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This Modularity Testing Framework helps you to write tests for modules
|
||||
# Copyright (C) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# he Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
||||
#
|
||||
|
||||
from avocado import main
|
||||
from avocado.core import exceptions
|
||||
from moduleframework import module_framework
|
||||
import time
|
||||
|
||||
|
||||
class SanityCheck2(module_framework.AvocadoTest):
|
||||
"""
|
||||
:avocado: enable
|
||||
"""
|
||||
|
||||
def testConnectToDB(self):
|
||||
self.start()
|
||||
time.sleep(5)
|
||||
self.run("psql -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -c 'SELECT 1'")
|
||||
|
||||
def testCreateTable(self):
|
||||
self.start()
|
||||
time.sleep(5)
|
||||
self.run("psql -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -c 'CREATE TABLE mytable(ID INT PRIMARY KEY NOT NULL);'")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
47
tests/simpleTest.py
Normal file
47
tests/simpleTest.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This Modularity Testing Framework helps you to write tests for modules
|
||||
# Copyright (C) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# he Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Authors: Jan Scotka <jscotka@redhat.com>
|
||||
#
|
||||
|
||||
from moduleframework import module_framework
|
||||
import os
|
||||
|
||||
|
||||
class simpleTests(module_framework.AvocadoTest):
|
||||
"""
|
||||
:avocado: enable
|
||||
"""
|
||||
|
||||
def testPath(self):
|
||||
print ">>>>>>>>>>>>>> ", module_framework.__file__
|
||||
print ">>>>>>>>>>>>>> ", __file__
|
||||
|
||||
def testAssertIn(self):
|
||||
self.start()
|
||||
self.assertIn("sbin", self.run("ls /").stdout)
|
||||
|
||||
def testInsideModule(self):
|
||||
self.start()
|
||||
self.assertEqual("a", self.run("echo a").stdout.strip())
|
||||
|
||||
def testCommandOnHost(self):
|
||||
self.start()
|
||||
self.assertEqual("a", self.runHost("echo a").stdout.strip())
|
||||
Loading…
Add table
Add a link
Reference in a new issue