From 7aaf6034818380d7c4973b7fc3ee571ea9f43772 Mon Sep 17 00:00:00 2001 From: asamalik Date: Mon, 15 May 2017 09:44:19 +0200 Subject: [PATCH 1/8] start f26 branch --- nginx.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.yaml b/nginx.yaml index a913cf3..dc21e44 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -7,9 +7,9 @@ data: module: [ MIT ] dependencies: buildrequires: - base-runtime: master + bootstrap: f26 requires: - base-runtime: master + bootstrap: f26 references: community: https://docs.pagure.org/modularity/ documentation: https://github.com/container-images/nginx From bb1d535e5fd98c189d22dbea9bb86bddf4c968f1 Mon Sep 17 00:00:00 2001 From: Radoslav Pitonak Date: Tue, 30 May 2017 14:01:17 +0200 Subject: [PATCH 2/8] test suite for nginx --- tests/Makefile | 1 - tests/config.yaml | 12 ++----- tests/configuration.py | 62 ++++++++++++++++++++++++++++++++ tests/rpmvalidator.py | 56 +++++++++++++++++++++++++++++ tests/sanity1.py | 63 +++++++++++++++++++++++++++++++++ tests/sanity2.py | 80 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 264 insertions(+), 10 deletions(-) create mode 100644 tests/configuration.py create mode 100644 tests/rpmvalidator.py create mode 100644 tests/sanity1.py create mode 100644 tests/sanity2.py diff --git a/tests/Makefile b/tests/Makefile index fa94987..8fd8ae7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -3,5 +3,4 @@ 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 index 9b9e3ee..32c9de8 100644 --- a/tests/config.yaml +++ b/tests/config.yaml @@ -12,18 +12,12 @@ testdependecies: - curl module: docker: - start: "docker run --rm -p 80:80 nginx" + start: "docker run -it -p 80:80 -p 443:443" source: https://github.com/container-images/nginx.git - container: docker.io/modularitycontainers/nginx + container: nginx rpm: start: systemctl start nginx stop: systemctl stop nginx status: systemctl status nginx repos: - - http://mirror.vutbr.cz/fedora/releases/25/Everything/x86_64/os/ -test: - processrunning: - - 'ls /proc/*/exe -alh | grep nginx' -testhost: - basic: - - 'curl localhost | grep "Welcome to nginx!"' + - http://mirror.vutbr.cz/fedora/releases/26/Everything/x86_64/os/ diff --git a/tests/configuration.py b/tests/configuration.py new file mode 100644 index 0000000..cc26131 --- /dev/null +++ b/tests/configuration.py @@ -0,0 +1,62 @@ +#!/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 +import time +from avocado.core import exceptions +from moduleframework import module_framework + + +class ConfigurationCheck(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def testConfChange(self): + """ + Test change the root directory in the configuration file of running nginx. + Then nginx is reloaded and should load website from new root directory. + """ + + self.start() + conf_path = "/etc/nginx/nginx.conf" + + content = "

Nginx is running in container!

" + root = "/tmp/app-root" + + # create website for testing + self.run("mkdir {}".format(root)) + self.run("echo '{}' >> {}/index.html".format(content, root)) + + # change the root directory inside conf file + self.run("sed -i 's/root.*$/root \/tmp\/app-root\/;/g' {}".format(conf_path)) + self.run("nginx -s reload") + + time.sleep(5) + + # request content from host + self.assertIn('{}\n'.format(content), self.runHost("curl 127.0.0.1:80").stdout) + + +if __name__ == '__main__': + main() diff --git a/tests/rpmvalidator.py b/tests/rpmvalidator.py new file mode 100644 index 0000000..8dc7541 --- /dev/null +++ b/tests/rpmvalidator.py @@ -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 +# + +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) diff --git a/tests/sanity1.py b/tests/sanity1.py new file mode 100644 index 0000000..cefd661 --- /dev/null +++ b/tests/sanity1.py @@ -0,0 +1,63 @@ +#!/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 SanityCheck1(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def test1(self): + """ + Simple sanity test + """ + + self.start() + self.run("ls / | grep bin") + + def test2Version(self): + """ + Check if nginx is installed in correct version + """ + + version = "1." + self.start() + + # For some reason, nginx -v spits out the version number to stderr + self.run("nginx -v 2>&1 | grep {}".format(version)) + + def test3ServiceRunning(self): + """ + Check if nginx is running + """ + + self.start() + self.run('ls /proc/*/exe -alh | grep nginx') + + +if __name__ == '__main__': + main() diff --git a/tests/sanity2.py b/tests/sanity2.py new file mode 100644 index 0000000..6794e2a --- /dev/null +++ b/tests/sanity2.py @@ -0,0 +1,80 @@ +#!/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 +import time + + +class SanityCheck2(module_framework.AvocadoTest): + """ + :avocado: enable + """ + + def test1Port80(self): + """ + Request to localhost inside the container to make sure that server running on port 80 + """ + + self.start() + time.sleep(2) + self.run("curl 127.0.0.1:80") + + def test2WebsiteContent(self): + """ + Check if nginx display correct content + """ + + content = "

Nginx is running in container!

" + root = "/usr/share/nginx/" + + self.start() + + # create simple static website inside the container + self.run("touch {}/html/index.html".format(root)) + self.run("echo '{}' >> {}/html/index.html".format(content, root)) + + # compare content returned by request from host with original content + self.assertIn('{}\n'.format(content), self.runHost("curl 127.0.0.1:80").stdout) + + def test3Port443(self): + """ + Test configure server to listen also on port 443 and make request from host. + """ + + conf_path = "/etc/nginx/nginx.conf" + self.start() + time.sleep(2) + + # Make the server listen on port 443. + self.run("sed -i 's/server {}$/ server {} listen 443;/g' {}".format("{", "{", conf_path)) + # reload nginx to apply changes + self.run("nginx -s reload") + time.sleep(5) + + self.runHost("curl 127.0.0.1:443") + + +if __name__ == '__main__': + main() From 91e0148f87f781ce4e7900c991aa93e4684489a7 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Tue, 30 May 2017 14:35:18 +0200 Subject: [PATCH 3/8] Add docker tests Signed-off-by: Petr "Stone" Hracek --- .gitignore | 1 + Dockerfile | 23 +++++++++++ files/nginx.conf | 94 ++++++++++++++++++++++++++++++++++++++++++ files/service.template | 11 +++++ 4 files changed, 129 insertions(+) create mode 100644 Dockerfile create mode 100644 files/nginx.conf create mode 100644 files/service.template 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..5d78b99 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM asamalik/module-nginx-master + +# Labels +LABEL name="nginx" \ + summary="Nginx is a web server." \ + description="Nginx is a web server, which can also be used as a reverse proxy, load balancer and HTTP cache." \ + version="0" \ + release="1" \ + atomic.has_install_files="true" + +# Add neccessary configuration files +COPY files/nginx.conf /etc/nginx/nginx.conf +COPY files/service.template /exports/hostfs/usr/lib/systemd/system/nginx-container.service + +RUN mkdir -p /exports/hostfs/{usr/share,etc} && \ + cp -ar /usr/share/nginx /exports/hostfs/usr/share/ && \ + cp -ar /etc/nginx /exports/hostfs/etc + +# Export port for nginx frontend +EXPOSE 80 + +# Start nginx +CMD ["/usr/sbin/nginx"] diff --git a/files/nginx.conf b/files/nginx.conf new file mode 100644 index 0000000..b25d737 --- /dev/null +++ b/files/nginx.conf @@ -0,0 +1,94 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/ +# * Official Russian Documentation: http://nginx.org/ru/docs/ + +user nginx; +worker_processes auto; +pid /run/nginx.pid; + +# Keep these settings to ensure the container runs correctly +error_log stderr; +daemon off; + +# Load dynamic modules. See /usr/share/nginx/README.dynamic. +include /usr/share/nginx/modules/*.conf; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 4096; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + include /etc/nginx/default.d/*.conf; + + location / { + + } + + error_page 404 /404.html; + location = /40x.html { + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + } + } + +# Settings for a TLS enabled server. +# +# server { +# listen 443 ssl http2 default_server; +# listen [::]:443 ssl http2 default_server; +# server_name _; +# root /usr/share/nginx/html; +# +# ssl_certificate "/etc/pki/nginx/server.crt"; +# ssl_certificate_key "/etc/pki/nginx/private/server.key"; +# ssl_session_cache shared:SSL:1m; +# ssl_session_timeout 10m; +# ssl_ciphers HIGH:!aNULL:!MD5; +# ssl_prefer_server_ciphers on; +# +# # Load configuration files for the default server block. +# include /etc/nginx/default.d/*.conf; +# +# location / { +# } +# +# error_page 404 /404.html; +# location = /40x.html { +# } +# +# error_page 500 502 503 504 /50x.html; +# location = /50x.html { +# } +# } + +} + diff --git a/files/service.template b/files/service.template new file mode 100644 index 0000000..9dc1660 --- /dev/null +++ b/files/service.template @@ -0,0 +1,11 @@ +[Unit] +Description="Standalone container version of NGINX webserver." + +[Service] +ExecStartPre=/usr/bin/docker create -t -i -v /etc/nginx:/etc/nginx/:ro --net=host -v /usr/share/nginx:/usr/share/nginx/:ro --name nginx-container modularitycontainers/nginx +ExecStart=/usr/bin/docker start -a nginx-container +ExecStop=/usr/bin/docker stop nginx-container +ExecStopPost=/usr/bin/docker rm -f nginx-container + +[Install] +WantedBy=multi-user.target From 92945c92570a71babe3cf37bdf9402884e53c205 Mon Sep 17 00:00:00 2001 From: Rafael Santos Date: Thu, 15 Jun 2017 16:06:29 +0000 Subject: [PATCH 4/8] Filter out nginx modules with broken deps --- nginx.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nginx.yaml b/nginx.yaml index dc21e44..9cf586d 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -21,6 +21,12 @@ data: api: rpms: - nginx + + filter: + rpms: + - nginx-all-modules + - nginx-mod-http-image-filter + components: rpms: nginx: From be2a9ea7e1b57b63fe11a39dd9ed68175b5cb560 Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: Thu, 22 Jun 2017 16:30:30 +0200 Subject: [PATCH 5/8] remove gperftools, part of shared-userspace --- nginx.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/nginx.yaml b/nginx.yaml index 9cf586d..e6dc83a 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -33,9 +33,6 @@ data: rationale: Provides API for this module. ref: f26 - gperftools: - rationale: dependency - ref: f26 libmnl: rationale: dependency ref: f26 From fde06595513d21134ffa2c002f3079f4ff90d5cc Mon Sep 17 00:00:00 2001 From: Jan Koscielniak Date: Mon, 26 Jun 2017 10:30:51 +0200 Subject: [PATCH 6/8] Fix links to tracker and documentation --- nginx.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.yaml b/nginx.yaml index e6dc83a..86b52a2 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -12,8 +12,8 @@ data: bootstrap: f26 references: community: https://docs.pagure.org/modularity/ - documentation: https://github.com/container-images/nginx - tracker: https://github.com/container-images/nginx + documentation: https://github.com/modularity-modules/nginx + tracker: https://github.com/modularity-modules/nginx profiles: default: rpms: From 5cc0b4a9c3f87c3fbe5593a87cfa5ceb09fc9952 Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: Wed, 28 Jun 2017 10:18:24 +0200 Subject: [PATCH 7/8] bump --- nginx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.yaml b/nginx.yaml index 86b52a2..d476f9c 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -2,7 +2,7 @@ document: modulemd version: 1 data: summary: nginx webserver - description: an initial version of the nginx webserver module + description: An initial version of the nginx webserver module license: module: [ MIT ] dependencies: From 652c63a56eaa1c49eae12f7ef41e4d285de03cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0abata?= Date: Thu, 13 Jul 2017 21:42:19 +0200 Subject: [PATCH 8/8] Removing duplicate content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libmnl, libnetfilter_conntrack and libnfnetlink are in base-runtime. libunwind is in shared-userspace. There's additional content shared with php and httpd but I'll leave that for now. Signed-off-by: Petr Ĺ abata --- nginx.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/nginx.yaml b/nginx.yaml index d476f9c..ea66662 100644 --- a/nginx.yaml +++ b/nginx.yaml @@ -33,18 +33,6 @@ data: rationale: Provides API for this module. ref: f26 - libmnl: - rationale: dependency - ref: f26 - libnetfilter_conntrack: - rationale: dependency - ref: f26 - libnfnetlink: - rationale: dependency - ref: f26 - libunwind: - rationale: dependency - ref: f26 libxkbcommon: rationale: dependency ref: f26