Skip to content

Commit

Permalink
Fix some issues with versioning of uwsgi in tests (#16316) (#16394)
Browse files Browse the repository at this point in the history
Actually use the build arguments in the docker file
Add build argument for the UWSGI version
Add supported-versions.yml
Reuse service definition in docker-compose.yml

(cherry picked from commit 34d0c35)
  • Loading branch information
jsoriano committed Feb 19, 2020
1 parent e8d1561 commit 85f6f66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
8 changes: 4 additions & 4 deletions metricbeat/module/uwsgi/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.6-alpine
ARG UWSGI_PYTHON_VERSION
FROM python:${UWSGI_PYTHON_VERSION}-alpine

ARG UWSGI_VERSION
RUN apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers curl
RUN pip install --no-cache-dir --trusted-host pypi.python.org uwsgi
RUN pip install --no-cache-dir --trusted-host pypi.python.org uwsgi==${UWSGI_VERSION}

WORKDIR /app
COPY testdata/app /app

HEALTHCHECK --interval=1s --retries=60 --timeout=10s CMD curl http://localhost:8080/
EXPOSE 8080 9191 9192

CMD [""]
2 changes: 2 additions & 0 deletions metricbeat/module/uwsgi/_meta/supported-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
variants:
- UWSGI_VERSION: 2.0.18
18 changes: 7 additions & 11 deletions metricbeat/module/uwsgi/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ version: '2.3'

services:
uwsgi_tcp:
image: docker.elastic.co/integrations-ci/beats-uwsgi:py${PYTHON_VERSION:-3.6}-1
image: docker.elastic.co/integrations-ci/beats-uwsgi:${UWSGI_VERSION:-2.0.18}-py${UWSGI_PYTHON_VERSION:-3.8}-1
build:
context: ./_meta
args:
PYTHON_VERSION: ${PYTHON_VERSION:-3.6}
command: uwsgi --http :8080 --master --processes 1 --threads 2 --stats 0.0.0.0:9191 --memory-report --wsgi-file app.py
UWSGI_VERSION: ${UWSGI_VERSION:-2.0.18}
UWSGI_PYTHON_VERSION: ${UWSGI_PYTHON_VERSION:-3.8}
ports:
- 9191
command: uwsgi --http :8080 --master --processes 1 --threads 2 --stats 0.0.0.0:9191 --memory-report --wsgi-file app.py

uwsgi_http:
image: docker.elastic.co/integrations-ci/beats-uwsgi:py${PYTHON_VERSION:-3.6}-1
build:
context: ./_meta
args:
PYTHON_VERSION: ${PYTHON_VERSION:-3.6}
command: uwsgi --http :8080 --master --processes 1 --threads 2 --stats 0.0.0.0:9192 --memory-report --stats-http --wsgi-file app.py
ports:
- 9192
extends:
service: uwsgi_tcp
command: uwsgi --http :8080 --master --processes 1 --threads 2 --stats 0.0.0.0:9191 --memory-report --stats-http --wsgi-file app.py
20 changes: 8 additions & 12 deletions metricbeat/module/uwsgi/test_uwsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import unittest
from nose.plugins.attrib import attr
from parameterized import parameterized

sys.path.append(os.path.join(os.path.dirname(__file__), '../../tests/system'))
import metricbeat
Expand All @@ -11,8 +12,9 @@
logger = logging.getLogger(__name__)


@metricbeat.parameterized_with_supported_versions
class Test(metricbeat.BaseTest):
COMPOSE_SERVICES = ['uwsgi_tcp']
COMPOSE_SERVICES = ['uwsgi_http', 'uwsgi_tcp']

def common_checks(self, output):
# Ensure no errors or warnings exist in the log.
Expand Down Expand Up @@ -52,16 +54,17 @@ def common_checks(self, output):
assert "requests" in cores[0]
assert "static" in cores[0]["requests"]

@parameterized.expand(["http", "tcp"])
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
@attr('integration')
def test_status(self):
def test_status(self, proto):
"""
uWSGI module outputs an event.
"""
self.render_config_template(modules=[{
"name": "uwsgi",
"metricsets": ["status"],
"hosts": [self.get_host()],
"hosts": [self.get_host(proto)],
"period": "5s"
}])
proc = self.start_beat()
Expand All @@ -71,12 +74,5 @@ def test_status(self):
output = self.read_output_json()
self.common_checks(output)

def get_host(self):
return "tcp://" + self.compose_host()


class TestHTTP(Test):
COMPOSE_SERVICES = ['uwsgi_http']

def get_host(self):
return "http://" + self.compose_host()
def get_host(self, proto):
return proto + "://" + self.compose_host(service="uwsgi_"+proto)

0 comments on commit 85f6f66

Please sign in to comment.