Compare commits

...
Sign in to create a new pull request.

8 commits

Author SHA1 Message Date
Petr Šabata
652c63a56e Removing duplicate content
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 <contyk@redhat.com>
2017-07-13 21:42:19 +02:00
Adam Samalik
5cc0b4a9c3 bump 2017-06-28 10:21:40 +02:00
Jan Koscielniak
fde0659551 Fix links to tracker and documentation 2017-06-26 10:30:51 +02:00
Adam Samalik
be2a9ea7e1 remove gperftools, part of shared-userspace 2017-06-22 16:30:30 +02:00
Rafael Santos
92945c9257 Filter out nginx modules with broken deps 2017-06-15 18:27:45 +02:00
Petr "Stone" Hracek
91e0148f87 Add docker tests
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
2017-05-30 14:35:18 +02:00
Radoslav Pitonak
bb1d535e5f test suite for nginx 2017-05-30 14:01:17 +02:00
asamalik
7aaf603481 start f26 branch 2017-05-15 09:44:19 +02:00
11 changed files with 404 additions and 30 deletions

1
.gitignore vendored
View file

@ -0,0 +1 @@
*.py[oc]

23
Dockerfile Normal file
View file

@ -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"]

94
files/nginx.conf Normal file
View file

@ -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 {
# }
# }
}

11
files/service.template Normal file
View file

@ -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

View file

@ -2,18 +2,18 @@ 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:
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
tracker: https://github.com/container-images/nginx
documentation: https://github.com/modularity-modules/nginx
tracker: https://github.com/modularity-modules/nginx
profiles:
default:
rpms:
@ -21,27 +21,18 @@ data:
api:
rpms:
- nginx
filter:
rpms:
- nginx-all-modules
- nginx-mod-http-image-filter
components:
rpms:
nginx:
rationale: Provides API for this module.
ref: f26
gperftools:
rationale: dependency
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

View file

@ -3,5 +3,4 @@ CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py
#
all:
generator
$(CMD)

View file

@ -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/

62
tests/configuration.py Normal file
View file

@ -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 <rpitonak@redhat.com>
#
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 = "<html><body><h1>Nginx is running in container!</h1></body></html>"
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()

56
tests/rpmvalidator.py Normal file
View 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)

63
tests/sanity1.py Normal file
View file

@ -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 <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):
"""
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()

80
tests/sanity2.py Normal file
View file

@ -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 <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 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 = "<html><body><h1>Nginx is running in container!</h1></body></html>"
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()