Commit fae5bba1 authored by Jérome Perrin's avatar Jérome Perrin

software/fluentd: drop python2 support

parent 7e78e14e
[buildout]
extends =
software.cfg
[python]
part = python2.7
...@@ -46,7 +46,6 @@ setup(name=name, ...@@ -46,7 +46,6 @@ setup(name=name,
'slapos.libnetworkcache', 'slapos.libnetworkcache',
'erp5.util', 'erp5.util',
'supervisor', 'supervisor',
'six',
], ],
zip_safe=True, zip_safe=True,
test_suite='test', test_suite='test',
......
...@@ -34,11 +34,10 @@ import struct ...@@ -34,11 +34,10 @@ import struct
import subprocess import subprocess
import tempfile import tempfile
import time import time
import six
import sys import sys
from six.moves.SimpleHTTPServer import SimpleHTTPRequestHandler from http.server import SimpleHTTPRequestHandler
from six.moves.socketserver import StreamRequestHandler, TCPServer from socketserver import StreamRequestHandler, TCPServer
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
from slapos.testing.utils import findFreeTCPPort from slapos.testing.utils import findFreeTCPPort
...@@ -49,8 +48,8 @@ FLUSH_INTERVAL = 1 ...@@ -49,8 +48,8 @@ FLUSH_INTERVAL = 1
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath( os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
'software%s.cfg' % ("-py2" if six.PY2 else ""))))
class FluentdTestCase(SlapOSInstanceTestCase): class FluentdTestCase(SlapOSInstanceTestCase):
__partition_reference__ = 'fluentd' __partition_reference__ = 'fluentd'
...@@ -135,11 +134,11 @@ class WendelinTutorialTestCase(FluentdTestCase): ...@@ -135,11 +134,11 @@ class WendelinTutorialTestCase(FluentdTestCase):
return subprocess.check_output( return subprocess.check_output(
[self._fluentd_bin, '-c', conf_path, '--dry-run'], [self._fluentd_bin, '-c', conf_path, '--dry-run'],
env={'GEM_PATH': self._gem_path}, env={'GEM_PATH': self._gem_path},
universal_newlines=True, text=True,
) )
def _test_configuration(self, expected_str): def _test_configuration(self, expected_str):
self.assertRegexpMatches( self.assertRegex(
self.read_fluentd_conf(self._conf), self.read_fluentd_conf(self._conf),
expected_str, expected_str,
) )
...@@ -168,12 +167,12 @@ class SensorConfTestCase(WendelinTutorialTestCase): ...@@ -168,12 +167,12 @@ class SensorConfTestCase(WendelinTutorialTestCase):
@classmethod @classmethod
def sensor_conf(cls, script_path): def sensor_conf(cls, script_path):
return '''\ return f'''\
<source> <source>
@type exec @type exec
tag tag.name tag tag.name
command %s %s command {sys.executable} {script_path}
run_interval %ss run_interval {FLUSH_INTERVAL}s
<parse> <parse>
keys pressure, humidity, temperature keys pressure, humidity, temperature
</parse> </parse>
...@@ -182,12 +181,12 @@ class SensorConfTestCase(WendelinTutorialTestCase): ...@@ -182,12 +181,12 @@ class SensorConfTestCase(WendelinTutorialTestCase):
@type forward @type forward
<server> <server>
name myserver1 name myserver1
host %s host {cls._ipv6_address}
</server> </server>
<buffer> <buffer>
flush_mode immediate flush_mode immediate
</buffer> </buffer>
</match>''' % (sys.executable, script_path, FLUSH_INTERVAL, cls._ipv6_address) </match>'''
@classmethod @classmethod
def sensor_script(cls, measurementList): def sensor_script(cls, measurementList):
...@@ -199,8 +198,7 @@ print("%s")''' % "\t".join(measurementList) ...@@ -199,8 +198,7 @@ print("%s")''' % "\t".join(measurementList)
def test_configuration(self): def test_configuration(self):
self._test_configuration( self._test_configuration(
r'adding forwarding server \'myserver1\' host="%s" port=%s weight=60' fr'adding forwarding server \'myserver1\' host="{self._ipv6_address}" port={FLUENTD_PORT} weight=60'
% (self._ipv6_address, FLUENTD_PORT)
) )
def test_send_data(self): def test_send_data(self):
...@@ -229,25 +227,24 @@ class GatewayConfTestCase(WendelinTutorialTestCase): ...@@ -229,25 +227,24 @@ class GatewayConfTestCase(WendelinTutorialTestCase):
@classmethod @classmethod
def gateway_conf(cls, fluentd_port, wendelin_port): def gateway_conf(cls, fluentd_port, wendelin_port):
return '''\ return f'''\
<source> <source>
@type forward @type forward
port %s port {fluentd_port}
bind %s bind {cls._ipv6_address}
</source> </source>
<match tag.name> <match tag.name>
@type wendelin @type wendelin
streamtool_uri http://[%s]:%s/erp5/portal_ingestion_policies/default streamtool_uri http://[{cls._ipv6_address}]:{wendelin_port}/erp5/portal_ingestion_policies/default
user foo user foo
password bar password bar
<buffer> <buffer>
flush_mode interval flush_mode interval
@type file @type file
path fluentd-buffer-file/ path fluentd-buffer-file/
flush_interval %ss flush_interval {FLUSH_INTERVAL}s
</buffer> </buffer>
</match>''' % (fluentd_port, cls._ipv6_address, cls._ipv6_address, </match>'''
wendelin_port, FLUSH_INTERVAL)
@classmethod @classmethod
def get_configuration(cls): def get_configuration(cls):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment