From a5499de9e0b17696990ddacbe96d794a493bb4b5 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 2 May 2017 14:35:14 +0200 Subject: [PATCH] First tests Signed-off-by: Petr "Stone" Hracek --- .gitignore | 1 + Dockerfile | 28 ++++++++++++++++++++++++++++ Makefile | 16 ++++++++++++++++ tests/Makefile | 8 ++++++++ tests/config.yaml | 30 ++++++++++++++++++++++++++++++ tests/generated.py | 25 +++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 tests/Makefile create mode 100644 tests/config.yaml create mode 100644 tests/generated.py diff --git a/.gitignore b/.gitignore index e69de29..c2956c7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +*.py[oc] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f88c3b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM registry.fedoraproject.org/fedora:26 + +# ruby image for OpenShift. +# +# Environment: + +ENV NAME=ruby ARCH=x86_64 +LABEL MAINTAINER "Jun Aruga" +LABEL summary="An interpreter of object-oriented scripting language" \ + name="$FGC/$NAME" \ + version="0" \ + release="1.$DISTTAG" \ + architecture="$ARCH" \ + com.redhat.component=$NAME \ + usage="docker run f26/ruby" \ + help="Runs ruby. No dependencies. See Help File below for more details." \ + description="An interpreter of object-oriented scripting language" \ + io.k8s.description="An interpreter of object-oriented scripting language" \ + io.k8s.diplay-name="Ruby 2.4 " \ + io.openshift.tags="ruby" + +RUN dnf install -y --setopt=tsflags=nodocs ruby && \ + dnf -y clean all + +# ruby will be run under standard user on Fedora +USER 1000 + +CMD /bin/bash diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef96813 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +IMAGE_NAME = ruby + +MODULEMDURL=file://ruby.yaml + +default: run + +build: + docker build --tag=$(IMAGE_NAME) . + +run: build + docker run -d $(IMAGE_NAME) + +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/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..df28881 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,8 @@ +MODULE_LINT=/usr/share/moduleframework/tools/modulelint.py +# --filter-by-tags=-WIP: ignore WIP tag test that have a issue on F25 avocado. +CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py + +# +all: + generator + $(CMD) diff --git a/tests/config.yaml b/tests/config.yaml new file mode 100644 index 0000000..2632cd0 --- /dev/null +++ b/tests/config.yaml @@ -0,0 +1,30 @@ +document: modularity-testing +version: 1 +name: ruby +modulemd-url: https://src.fedoraproject.org/cgit/modules/ruby.git/plain/ruby.yaml +service: + port: 8080 +packages: + rpms: + # add which here because of the issue. + # https://pagure.io/modularity-testing-framework/issue/45 + - ruby +testdependecies: + rpms: + - which +module: + docker: + start: "docker run -it" + container: docker.io/ruby + rpm: + repos: + - http://download.eng.brq.redhat.com/pub/fedora/linux/development/rawhide/Everything/x86_64/os/ + - http://download.eng.brq.redhat.com/pub/fedora/linux/development/26/Everything/x86_64/os/ +test: + cmd: + - 'which ruby' + version: + - 'ruby -v' +testhost: + hostname: + - 'hostname' diff --git a/tests/generated.py b/tests/generated.py new file mode 100644 index 0000000..3d31f62 --- /dev/null +++ b/tests/generated.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +import socket +from avocado import main +from moduleframework import module_framework + +if __name__ == '__main__': + main() + +class GeneratedTestsConfig(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def test_cmd(self): + self.start() + self.run("which ruby") + + def test_version(self): + self.start() + self.run("ruby -v") + + def test_hostname(self): + self.start() + self.runHost("hostname")