From f8c3b4db33778b4baf32af8c7924918d5c1e5630 Mon Sep 17 00:00:00 2001 From: Radoslav Pitonak Date: Jun 08 2017 11:19:50 +0000 Subject: general tests for module --- diff --git a/.gitignore b/.gitignore index e69de29..5678398 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +*.idea* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c2c116 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM baseruntime/baseruntime:latest + +LABEL MAINTAINER Rado Pitonak + +RUN microdnf --nodocs install php && \ + microdnf -y clean all + +CMD bash diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8b6941b --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +IMAGE_NAME = php + +MODULEMDURL=file://php.yaml + +default: run + +build: + docker build --tag=$(IMAGE_NAME) . + +run: build + docker run -d $(IMAGE_NAME) + +debug: build + docker run -it $(IMAGE_NAME) bash + +test: build + cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..8fd8ae7 --- /dev/null +++ b/tests/Makefile @@ -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) diff --git a/tests/config.yaml b/tests/config.yaml new file mode 100644 index 0000000..a2c06a9 --- /dev/null +++ b/tests/config.yaml @@ -0,0 +1,16 @@ +document: modularity-testing +version: 1 +name: php +modulemd-url: http://pkgs.fedoraproject.org/cgit/modules/php.git/plain/php.yaml?h=f26 +service: + port: 8080 +packages: + rpms: + - php +module: + docker: + start: "docker run -it" + container: php + rpm: + repos: + - http://mirror.vutbr.cz/fedora/releases/26/Everything/x86_64/os/ diff --git a/tests/sanity1.py b/tests/sanity1.py new file mode 100644 index 0000000..4ed53a7 --- /dev/null +++ b/tests/sanity1.py @@ -0,0 +1,60 @@ +#!/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 +# + +from avocado import main +from avocado.core import exceptions +from moduleframework import module_framework + + +class SanityCheck(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def testPhpBinary(self): + """ + Simple sanity test + """ + + self.start() + self.run("ls /bin | grep php") + + def test2PHPVersion(self): + """ + Check if PHP is installed in correct version + """ + version = "7." + self.start() + self.run("php -v | grep {}".format(version)) + + def testScriptExecution(self): + """ + Execute simple PHP script from CLI + """ + output = "Hello world!" + self.start() + self.assertIn(output, self.run("php -r 'echo \"{}\";'".format(output)).stdout) + + +if __name__ == '__main__': + main()