From dafb6e09f1db9d5d9fecbd2bd986430f0e9031da Mon Sep 17 00:00:00 2001 From: psklenar Date: Mar 20 2017 09:27:17 +0000 Subject: init of haproxy test --- diff --git a/examples/haproxy/config.yaml b/examples/haproxy/config.yaml new file mode 100644 index 0000000..7c7a1b7 --- /dev/null +++ b/examples/haproxy/config.yaml @@ -0,0 +1,32 @@ +document: modularity-testing +version: 1 +name: haproxy +modulemd-url: https://raw.githubusercontent.com/container-images/haproxy/master/haproxy.yaml +service: + port: 80 +packages: + rpms: + - haproxy +testdependecies: + rpms: + - nc +module: + docker: + start: "docker run -it -p 80:80 -v $(pwd)/local-haproxy.cfg:/etc/haproxy/haproxy.cfg" + 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: systemctl start haproxy + stop: systemctl stop haproxy + status: systemctl status haproxy + repos: + - http://download.englab.brq.redhat.com/pub/fedora/releases/25/Everything/x86_64/os/ + - https://phracek.fedorapeople.org/haproxy-module-repo/ + test: + processrunning: + - 'ls /proc/*/exe -alh | grep haproxy' + + diff --git a/examples/haproxy/my-haproxy.cfg b/examples/haproxy/my-haproxy.cfg new file mode 100644 index 0000000..3e1e8a4 --- /dev/null +++ b/examples/haproxy/my-haproxy.cfg @@ -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 + diff --git a/examples/haproxy/simpleTest.py b/examples/haproxy/simpleTest.py new file mode 100755 index 0000000..23f0706 --- /dev/null +++ b/examples/haproxy/simpleTest.py @@ -0,0 +1,32 @@ +#!/usr/bin/python + +from moduleframework import module_framework +import os + + +class simpleTests(module_framework.AvocadoTest): + """ + :avocado: enable + """ + def setUp(self): + super(self.__class__, self).setUp() + 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() + + def tearDown(self): + super(self.__class__, self).tearDown() + self.runHost('docker stop http_name_8000') + self.runHost('docker stop http_name_8001') + self.runHost('docker rm http_name_8000') + self.runHost('docker rm http_name_8001') + + def testAssertIn(self): + + self.runHost('sed s/127.0.0.1/%s/ my-haproxy.cfg > local-haproxy.cfg' % myip, shell=True) + self.runHost('chcon -t etc_t local-haproxy.cfg') + self.start() + self.assertIn('It works!',self.runHost('curl localhost:80').stdout) + diff --git a/moduleframework/module_framework.py b/moduleframework/module_framework.py index d535c5a..c82e909 100644 --- a/moduleframework/module_framework.py +++ b/moduleframework/module_framework.py @@ -126,7 +126,7 @@ class ContainerHelper(CommonFunctions): if 'start' in self.info and self.info['start']: self.docker_id = utils.process.run( "%s -d %s" % - (self.info['start'], self.jmeno)).stdout + (self.info['start'], self.jmeno), shell=True).stdout else: self.docker_id = utils.process.run( "docker run %s %s %s" %