diff --git a/.gitignore b/.gitignore index 485dee6..b6a895f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .idea +tests/*.pyc +.idea +tests/localrepo* diff --git a/Dockerfile b/Dockerfile index b95208c..c9f9da9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ FROM baseruntime/baseruntime:latest COPY repos/* /etc/yum.repos.d/ +COPY tests/scripts/* /tmp/ -RUN microdnf --nodocs --enablerepo perl install perl perl-devel && \ +RUN sed -i 's|/jkaluza/|/ralph/|g' /etc/yum.repos.d/build.repo && \ + rpm -e --justdb --nodeps systemd-libs && \ + microdnf --nodocs --enablerepo perl install perl perl-devel && \ microdnf clean all EXPOSE 8080 diff --git a/Makefile b/Makefile index e02c0da..8b48706 100644 --- a/Makefile +++ b/Makefile @@ -12,4 +12,3 @@ run: build test: build cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all - cd tests; MODULE=rpm MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all diff --git a/repos/perl.repo b/repos/perl.repo index 63394b1..0f32e9d 100644 --- a/repos/perl.repo +++ b/repos/perl.repo @@ -1,4 +1,4 @@ [perl] name=perl -baseurl=https://kojipkgs.fedoraproject.org/repos/module-fcd86adc7a9c7e0a/latest/x86_64/ +baseurl=https://kojipkgs.fedoraproject.org/repos/module-9ac9f492d4852dfd-build/latest/x86_64/ enabled=0 diff --git a/tests/cpan.py b/tests/cpan.py index 38478b1..6e34c87 100644 --- a/tests/cpan.py +++ b/tests/cpan.py @@ -22,24 +22,34 @@ from avocado import main from avocado.core import exceptions from moduleframework import module_framework -class CpanCheck1(module_framework.AvocadoTest): + + +class CpanCheck(module_framework.AvocadoTest): """ :avocado: enable """ def testInstallPerlModule(self): + """ + Installing Perl module using cpan [http://www.cpan.org/] + """ + self.start() + self.run("microdnf --nodocs --enablerepo fedora install -y cpan cpanminus") self.run("cpanm install --force Error") self.run("perl -e \"use Error\"") def testInstallCModule(self): + """ + Installing Perl module written in C language, using cpan [http://www.cpan.org/] + Another packages need to be install here - gcc, rpm-devel to build module. + """ + self.start() - # install cpan + self.run("microdnf --nodocs --enablerepo fedora install -y cpan cpanminus") - # install gcc and rpm-devel self.run("microdnf --nodocs --enablerepo fedora install -y gcc rpm-devel") - # install random c module self.run("cpanm install --force RPM2") self.run("perl -e \"use RPM2\"") diff --git a/tests/microdnfinside.py b/tests/microdnfinside.py deleted file mode 100644 index 479487d..0000000 --- a/tests/microdnfinside.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 -# - -from moduleframework import module_framework -import os - - -class microDNFTest(module_framework.AvocadoTest): - """ - :avocado: enable - """ - - def testInstallMicroDNFEmpty(self): - self.start() - self.assertIn("Transaction: (empty)",self.run("microdnf install microdnf", ignore_status=True).stdout) diff --git a/tests/sanity1.py b/tests/networking.py similarity index 75% rename from tests/sanity1.py rename to tests/networking.py index 602418c..18825c3 100644 --- a/tests/sanity1.py +++ b/tests/networking.py @@ -24,21 +24,20 @@ from avocado import main from avocado.core import exceptions from moduleframework import module_framework -class SanityCheck1(module_framework.AvocadoTest): + + +class NetworkingCheck(module_framework.AvocadoTest): """ :avocado: enable """ - def test1(self): + def testHTTPRequest(self): + """ + Test networking with `HTTP::Tiny` perl module + Testing script is included in `scripts` folder + """ self.start() - self.run("ls / | grep bin") - - # check if perl is installed in the right version. - def test2PerlVersion(self): - perlVersion = "5.24" - module_framework.skipTestIf("perl" not in self.getActualProfile()) - self.start() - self.run("perl -v | grep " + perlVersion) + self.run("perl /tmp/http.pl") if __name__ == '__main__': diff --git a/tests/simpleTest.py b/tests/sanity.py similarity index 57% rename from tests/simpleTest.py rename to tests/sanity.py index 780e387..65abed9 100644 --- a/tests/simpleTest.py +++ b/tests/sanity.py @@ -18,30 +18,43 @@ # 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 +# Authors: Rado Pitonak # +from avocado import main +from avocado.core import exceptions from moduleframework import module_framework -import os -class simpleTests(module_framework.AvocadoTest): +class SanityCheck(module_framework.AvocadoTest): """ :avocado: enable """ - def testPath(self): - print ">>>>>>>>>>>>>> ", module_framework.__file__ - print ">>>>>>>>>>>>>> ", __file__ + def test1(self): + """ + Simple sanity test + """ - def testAssertIn(self): self.start() - self.assertIn("sbin", self.run("ls /").stdout) + self.run("ls / | grep bin") - def testInsideModule(self): + def test2PerlVersion(self): + """ + Check if perl is installed in correct version + """ + perl_version = "5.24" self.start() - self.assertEqual("a", self.run("echo a").stdout.strip()) + self.run("perl -v | grep " + perl_version) - def testCommandOnHost(self): + def testPerlScript(self): + """ + Executing simple perl script + """ + test_string = "Running test script\n" self.start() - self.assertEqual("a", self.runHost("echo a").stdout.strip()) + self.assertIn("{}".format(test_string), self.run('perl -e " print \'{}\'"'.format(test_string)).stdout) + + +if __name__ == '__main__': + main() diff --git a/tests/scripts/http.pl b/tests/scripts/http.pl new file mode 100644 index 0000000..d38a88a --- /dev/null +++ b/tests/scripts/http.pl @@ -0,0 +1,5 @@ +use HTTP::Tiny; + +my $response = HTTP::Tiny->new->get('http://example.com/'); + +die "Failed!\n" unless $response->{success}; \ No newline at end of file