Update tests based on correction Jan Scotka

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
This commit is contained in:
Petr "Stone" Hracek 2017-04-04 23:30:25 +02:00
commit 3c7c53d0f5
3 changed files with 41 additions and 13 deletions

View file

@ -10,22 +10,26 @@ packages:
testdependecies:
rpms:
- nc
source: https://github.com/container-images/haproxy
module:
docker:
setup:
cp my-haproxy.cfg local-haproxy.cfg
start: "docker run -it -p 8077:80 -v $(pwd)/local-haproxy.cfg:/etc/haproxy/haproxy.cfg:Z"
labels:
description: "HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments."
io.k8s.description: "HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments."
source: https://github.com/container-images/haproxy
container: docker.io/modularitycontainers/haproxy
rpm:
start: sed -i 's/bind\*/bind :8077/' $(pwd)/local-haproxy.cfg;
cp $(pwd)/local-haproxy.cfg /etc/haproxy/haproxy.cfg;
semanage port -a -t http_port_t -p tcp 8001;
semanage port -a -t http_port_t -p tcp 8000;
semanage port -a -t http_port_t -p tcp 8077;
sleep 4;
systemctl start haproxy
setup:
sed s/127.0.0.1/`hostname -i | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'`/ my-haproxy.cfg > local-haproxy.cfg;
sed -i 's/bind\*/bind :8077/' local-haproxy.cfg;
cp $(pwd)/local-haproxy.cfg /etc/haproxy/haproxy.cfg;
semanage port -a -t http_port_t -p tcp 8001;
semanage port -a -t http_port_t -p tcp 8000;
semanage port -a -t http_port_t -p tcp 8077;
sleep 4;
start: systemctl start haproxy
stop: systemctl stop haproxy
status: systemctl status haproxy
repos:

26
tests/local-haproxy.cfg Normal file
View file

@ -0,0 +1,26 @@
# Example from http://www.haproxy.org/download/1.3/examples/antidos.cfg
# This configuration is meant to be installed in front of an existing web
# server that needs some DoS protection. We assume that the web server has been
# moved to port 8080 on the loopback, and that haproxy 1.3.18 is running on
# port 80. Note that Apache will have to be configured to get the client's IP
# address from the X-Forwarded-For header (mod_rpaf can do that).
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind :80
default_backend servers
backend servers
server server1 127.0.0.1:8000 maxconn 32
server server2 127.0.0.1:8001 maxconn 32

View file

@ -23,7 +23,7 @@
from moduleframework import module_framework
import os
import time
class simpleTests(module_framework.AvocadoTest):
"""
@ -34,8 +34,7 @@ class simpleTests(module_framework.AvocadoTest):
self.runHost('docker pull docker.io/httpd')
self.runHost('docker run --name http_name_8000 -d -p 8000:80 docker.io/httpd')
self.runHost('docker run --name http_name_8001 -d -p 8001:80 docker.io/httpd')
global myip
myip = self.runHost('hostname -i').stdout.strip()
time.sleep(5)
def tearDown(self):
super(self.__class__, self).tearDown()
@ -45,7 +44,6 @@ class simpleTests(module_framework.AvocadoTest):
self.runHost('docker rm http_name_8001')
def testAssertIn(self):
self.runHost(('sed s/127.0.0.1/{}/ my-haproxy.cfg > local-haproxy.cfg').format(myip), shell = True)
self.start()
self.assertIn('It works!',self.runHost('curl localhost:8077', shell = True).stdout)
self.assertIn('It works!',self.runHost('curl localhost:8077').stdout)